I have a field like so
const SimpleReactComponent = (props) => {
const [title, setTitle] = useState('DEFAULT')
useEffect(() => {
return () => {
// unmount
console.log(`[${title}] while unmounting`)
}
}, [])
return <TextInput value={title} onChangeText={title => setTitle(title)}></TextInput>
}
When I modify the title
field and navigate away from this component, it still prints the following
[DEFAULT] while unmounting
While I'm expecting the newly modified value instead of DEFAULT
.
How to capture the changes while component is unmounting?