Skip to main content

All Questions

2 votes
1 answer
47 views

How to make an API call to check wether a user is valid or not on every component rendering in react?

I have a user authentication app, once a user logs in I save his data on the redux store and use it to manage the authenticated state through redux. But this never gave real-time data. Say, that the ...
Ahammed Zulaikh's user avatar
1 vote
3 answers
436 views

React API data and Routing

I am new to React. Trying to build random project. I create one home page where I fetched data from API and set it to some state X. Using react-router, routed to Category page where all categories are ...
Ashish Gahlot's user avatar
-1 votes
1 answer
104 views

I am getting array of objects from backend but can't set them into React states [duplicate]

I am getting back-end data by using axios.get(), but the array of objects is not populating the state. It's giving me following in the console. Outside Effect {success: true, message: 'All Categories ...
Aritra Mukherjee's user avatar
-3 votes
1 answer
38 views

Why .then() which is in useEffect is not updating my state

targetMovie is null when it comes to rednering. I couldn't find any solutions. First time having unsolvable problem. Please help! async function getMovie(id) { try { const res = await axios.get(...
Ali Ahmadi's user avatar
0 votes
2 answers
41 views

Reac router component in a list as a state

does anyone have experience with React routers?Is there a way to create a list of routes and hold it in a usestate? When i try to do the [... prevCountryRoutes] i get the error that ...
Maarten Baeten's user avatar
3 votes
1 answer
2k views

I have a problem with React Router Dom V6 and useState

I have a problem with navigation between two routes of same component. I have a page where there is a form to create and edit user. The routes are: /user /user/:id But when try navigate from /user/:id ...
Lucas K C's user avatar
1 vote
1 answer
852 views

How to update state when props from Link change?

I'm fetching data from a smart contract in component1 like this (this is a menu with Links: const [contract, setContract] = useState() const [projects, setProjects] = useState([]) const getData = ...
enchante's user avatar
0 votes
1 answer
3k views

React conditional render for logged in / logged out User only updates state with browser refresh

I'm building a React app using hooks and functional components for the front end to a Rails backend API with Cookie / Session authentication. Everything is working well as far as getting users logged ...
firesoflife's user avatar
1 vote
1 answer
3k views

How to use ProtectedRoute (RequireAuth) with fetch(url, method) in React (React Router v6)?

I want to redirect users to Unprotected (login/ register) components if the user is not logged in (or verified) else allow access to Protected components. To achieve that, I tried to use, ...
Mohammed Julfikar Ali Mahbub's user avatar
2 votes
2 answers
3k views

React router <Redirect> is not redirecting on state

The app should redirect to /dashboard when user is not null. User is null in the first render but useEffect() should pick up and store user data from local storage. Then, the ternary operator should ...
Htet Oo Wai Yan's user avatar
0 votes
2 answers
72 views

Show image details of selected image

I'm using an API that returns random images each time. The app currently displayed 6 random images from the API, however I'm now trying to achieve a page that displays the image data, such as the date,...
user avatar
0 votes
3 answers
690 views

Adding a new DishdetailComponent to React application to displays the details of a Specific dish

I am new to React and I am facing a issue to get item details when an item is clicked in React from an another Dishdetail component. I have MenuComponent.js which is supposed to call the ...
divyanshu_31's user avatar
1 vote
0 answers
29 views

React - State value sometimes wrong when using Router

I am new to React, and I have noticed when sending a state value via Router in onSubmit, the value for spaghetti in the next page is sometimes wrong. Here is a piece of my code: const ItalianMenu=()=&...
Pink Jazz's user avatar
  • 802
1 vote
1 answer
25 views

Better way to catch the state of my action in my app + react-redux +react-router

I create an example to use react-redux in my app that is working and print the value of my test, my doubt here is exist other way to catch the state of the store and don't write the code login[0].user ...
cdiegobb's user avatar
3 votes
0 answers
34 views

I want to show only mapped URL instead of project URL mixing

I'm new to react. I have a problem with url. I get data from Github API through fetch request. Now I have to show only URL from API data but it shows me project url and data url mixed. Here's the code ...
Ahsan Danish's user avatar

15 30 50 per page