Open radulle opened 4 years ago
@radulle did you ever get this working with hooks? I haven't tried to convert my implementation yet.
Any news on this one? The error message is actually just a warning and everything seems to work. But it might break in future versions of React.
This is related to the following React issue: https://github.com/facebook/react/issues/18147
Ref. comment: https://github.com/facebook/react/issues/18147#issuecomment-592267650
The problem is that the proposed solution would require components in react-sortable-tree to be converted from class components to functional ones...
I have the same issue!
Any news on this one? I have the same problem~
after going through this issue and reading this, I understood that the warning gets triggered if you want to setState a component synchronously from a different component.
So I have found a workaround to make the warning disappear, till it's fixed.
If you click on the little arrow beside Warning, you'll get a much detailed stacktrace.
For me, I have found the warning is triggered by the callback I pass to searchFinishCallback
(because it's there where I change the state of my component from SortableTree
component).
So, I changed my callback from something like this:
const searchFinishCallback = (matches) => {
setSearchFoundCount(matches.length)
setSearchFocusIndex((searchFocusIndex) =>
matches.length > 0 ? searchFocusIndex % matches.length : 0
)
}
To something like this:
const searchFinishCallback = (matches) => {
setImmediate(() => {
setSearchFoundCount(matches.length)
setSearchFocusIndex((searchFocusIndex) =>
matches.length > 0 ? searchFocusIndex % matches.length : 0
)
})
}
You can instead use setTimeout
or anything that will make the call async.
When storyboard class component search example is converted to functional (hooks) errors/warnings are thrown.