State Update on Unmounted Component
dustinlacewell opened this issue · 1 comments
dustinlacewell commented
When using React Router, when ink-text-input become unmounted it throws the following error:
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
in TextInput (created by Test)
in ink-box (created by Box)
in Box (created by Test)
in Test (created by Start)
in ink-box (created by Box)
in Box (created by Start)
in ink-box (created by Box)
in Box (created by Fullscreen)
in Fullscreen (created by Start)
in Start (created by Context.Consumer)
```
vadimdemedes commented
Tried reproducing it with this, but didn't see that error:
const React = require('react')
const {Box, Text, render} = require('ink')
const TextInput = require('.').default
const Example = () => {
const [show, setShow] = React.useState(true)
const [value, setValue] = React.useState('')
const submit = React.useCallback(() => {
setShow(false)
}, [])
return <Box>
{show && <TextInput value={value} onChange={setValue} onSubmit={submit}/>}
{!show && <Text>Got the input</Text>}
</Box>
}
render(<Example/>)