Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State Update on Unmounted Component #66

Open
dustinlacewell opened this issue Jul 26, 2021 · 1 comment
Open

State Update on Unmounted Component #66

dustinlacewell opened this issue Jul 26, 2021 · 1 comment

Comments

@dustinlacewell
Copy link

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
Copy link
Owner

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/>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants