score:1
I guess that the problem is - In editTodo
function, you are calling getTodos()
function. But, you are not updating the state with the response you get. See if this helps.
const response = await fetch(
`http://localhost:5000/todos/${selectedId}`,
{
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body)
}
);
console.log(response);
setTodo(await getTodos()); // Update the state with the values from fetch
Source: stackoverflow.com
Related Query
- setState hook not updating after fetch with HTTP PUT
- Why my usestate hook value is not updating after onClick event with no error at all?
- setState call inside a custom hook is not updating the state
- React not updating state with setState with Array of object
- Replace of setState callback in react hook with useEffect hooks for complicated scenario not working
- React useState hook not updating with axios call
- React hook useState not updating with onSubmit
- React setState hook not working with useEffect
- React setState hook not updating dependent element if passed a variable as opposed to explicit text
- Why is React setState hook not updating immediately?
- Updating object with useState Hook after rendering text input
- React Not Updating Render After SetState
- ReactJS Context re-render after a fetch with useEffect hook
- React custom hook with event listener not works while updating the state
- React hook not updating after the API call
- My UI is not updating with latest data after react-query mutation
- functional component not re-rendering after setState update hook
- How to setstate after fetch data React hook
- React updating a setState with a callback to a useState hook
- SetState with react hook and redux after async call to axios API
- React component not updating after prop is updated using setState
- React 'useContext' hook not re-rendering after context updates with database data
- React not updating state with setState correctly inside promises
- React state not updating after fetch .then statement
- setState not updating state after useEffect
- React Component not updating after calling setState in SocketIO event listener
- ReactJs setState updating not in sync with what is being typed in the input box
- users array hook is not updating with all the list items
- Attempting to access data after fetching with custom hook not working
- Data is not updating with React Hook useEffect()
More Query from same tag
- I can't implement a Lightbox Gallery on React
- How to get the width of a react element
- How does react-redux know what store fragment to pass?
- How to switch between CSS styles of React components when changing routes?
- Calling React Component function from JS function
- Refreshing component after making api call Reactjs
- How to style ButtonGroup with variant='text' in Material UI?
- How can I add an icon to Material-UI Select?
- Initialize materializecss component in React
- Why does Typescript flag a possible undefined value on array length check with greater than but not equals?
- When and why to useEffect
- useForm is called in function which is neither a React function component... error
- Problem with asynchronous function type Promise<faceProductList[] | string>
- Conditional Statement inside Component Tag
- ReactJs development on docker container
- Render React component from instantiated React.Component
- How do I use a custom DOM node to render to from within a react component
- How do I attach the enum value to an object, instead of the enum name?
- Unicode JSON in Laravel blade for use in React, generating a JSON.parse problem
- Is using setState in every iteration of a loop bad practice?
- How to fix this Maximum depth exceeded error with useEffect and useState?
- How to keep the fetching queue in order
- Push to / Update an Array in React JS State
- use a variable in other component in Reactjs
- Express ENOENT: no such file or directory, stat '/index.html'
- How to change button text in ReactJS
- state is not incrementing correctly reactjs
- Is there a way to put requirements on hook dependencies?
- Simple setState on object using hooks
- .map undefined on array of object