score:1
i can't comment because i've only just made an account
that being said i can update this answer if you can provide a bit more information :)
where are you checking for the result of the new chore being set? i can see in the code you posted that there's the new chore index being logged in the updatechore
function but not the newchore
itself. have you tried logging in another useeffect
? like...
useeffect(() => {
console.log(newchore);
}, [newchore]);
* update
seeing as you're only using newchore
inside the popup, you could try moving the usestate
call for newchore
inside of the popup body then passing it to the updatechore
function like this
const [showpopup, hidepopup] = usepopup('popup', ({ message, handleclose }) => {
const [newchore, setnewchore] = usestate("");
useeffect(() => {
console.log(newchore);
}, [newchore]);
return (
<div classname="modal">
<div classname="modalinner">
<button
classname="modalclose"
onclick={handleclose}>
x
</button>
<div classname="modalinner2">
<p classname="modalheading">previous chore(s)</p>
<p classname="modalchore">{message}</p>
<p classname="modalheading">new chore {newchoreindex}</p>
<input
classname="newchoreinput"
placeholder="new chore"
onchange={(e) => {setnewchore(e.target.value)}}
/>
<button
classname="modalsubmit"
onclick={() => {
updatechore(newchore)
hidepopup()
}}>
update chore
</button>
</div>
</div>
</div>
)
});
this will stop the useeffect
on setchore
working outside of the popup though as it's not in scope, so you'll probably have to move that into the popup as well to see if it's updating on change.
Source: stackoverflow.com
Related Query
- React Hook setState function not updating value
- React hook value not updating in async function
- React Hook useCallback not updating State value
- React setState hook not updating dependent element if passed a variable as opposed to explicit text
- Why is React setState hook not updating immediately?
- setState in react function not updating in promise method
- React useState not updating value in async function
- State variable inside a function defined within useEffect hook is not updating when value changes
- Custom react hook not updating it's value
- update function returned by useState hook not updating the value
- react hook not updating when referencing another hook value
- React JS setState not updating value
- React does not change state after updating state in usestate hook (in custom function form)
- Unable to update a list with react when its value is being changed using the hook useState function from React TypeError: map is not a function
- SetState not updating the value in react js functional component
- React setState hook not updating OUTSIDE a loop
- React setState of useState hook successfully updating state, but not re-rendering component
- React setState of boolean value not updating
- React setState function from useState not updaing state value
- React useState hook attached to an Input type number not updating value on mouse scroll
- React hook useSelector value not changed inside async function
- setState is not updating value in react Componet
- State not updating when using React state hook within setInterval
- React setState not updating state
- React setState not Updating Immediately
- Uncaught TypeError: create is not a function using useEffect React Hook with AJAX request
- React hooks value is not accessible in event listener function
- React Native: setState not updating immediately when logging in console
- React hook not updated in function listened on scroll event
- setState not working for updating an array in React
More Query from same tag
- React-native: Keep animated values in state or as class property?
- How do I apply a margin to a React component without modifying the component itself?
- How to fix jslint error 'Don't make functions within a loop.' while using find function inside loop
- Downshift in Reactjs - Menu dropdown only displaying selected item
- React TypeScript: Custom hook looping infinitely
- handle multiselect case on selecting and deselecting button/component
- How to get another component when I click h1 tag in react using hooks?
- Correct way to type nullable state when using React's useState hook
- Testing render props component
- How change the styling of dynamically generated JSX via a button click in React Native
- React js : items never fed in infinite scroll (now with simpler example)
- How to call onEnter function on Route in React Router Multiple times
- React: Updating state when state is an array of objects
- 404 not found when using socket.io-client with react
- Angular JS ng-repeat filter alternative in React JS
- react-redux not updating state when the API returns an empty array []
- I am trying to work with useQuery in Typescript
- oidc-client or oidc-token-manager in react+flux application
- API response not updating after x seconds reactJS
- ReacJS Axios patch request URL with state not working
- Summernote rich text editor-restrict image above particular height and width
- "firebase" is added as a dependency in your project's package.json but it doesn't seem to be installed
- Get figure from function and set it as state once user types in input
- Generic React components in TypeScript/JSX?
- How to send FormData attribute with an array of strings from React Client to Django + Django Rest Framework API
- How to use css-in-js in ant-design components?
- How to use @media to change width in prop styled components
- Failed to compile: Module not found: Can't resolve './components/MyInfo' in 'c:\xampp\htdocs\reactjs\src'
- Gatsby / Graphql - Can't display img from query
- How to Use/Make Callback Function with SetState