Skip to content

Set state on unmounted component #278

Closed
@kamilkazmierczakMtab

Description

@kamilkazmierczakMtab

Describe the bug
TreeEnvironment in some circumstances can call setState on unmounted component.
Error I get
Warning: Can't perform a React state update on a component that hasn't mounted yet. This indicates that you have a side-effect in your render function that asynchronously later calls tries to update the component. Move this work to useEffect instead.

Issue occurs because of set state call inside onMissingItems
https://github.com/lukasbach/react-complex-tree/blob/main/packages/core/src/uncontrolledEnvironment/UncontrolledTreeEnvironment.tsx#L202

To Reproduce
Hard to reproduce - in my case warning is always thrown because component is rendered inside Layout of react-router-dom

Expected behavior
Warning is not shown

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions