If the component is open while it's being triggered through a state change the component stops functioning
See original GitHub issueDescribe the bug
When opening the Collapsible component via a mouse click
and then triggering the component to open/close via a state change of the parent component by passing through a value via the open
API the component stop functioning all together.
To Reproduce
- Wait for the app to load
- Click on
Accordion #1
(doesn’t really matter which one) - Click on the checkbox above to open all Collapsible components on the page
4a. Click again on the checkbox and nothing will happen to
Accordion #1
4b. Click again onAccordion #1
and nothing will happen - The component has stopped working
Here’s a sandbox already setup with the https://codesandbox.io/s/dark-star-t2g3ou?file=/src/App.js
Expected behavior The component should open/close normally
Authors notes If this is somehow my fault for not fully understanding reacts hooks lifecycle or in general my mistake, but I’m still new to react
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6
Top Results From Across the Web
When does React re-render components?
Changing the state means that React triggers an update when we call the setState function (in React hooks, you would use useState )....
Read more >Why React doesn't update state immediately
When developing React applications, you may have noticed that state updates don't immediately reflect new values after being changed.
Read more >Using the Effect Hook
They let you use state and other React features without writing a class. The Effect Hook lets you perform side effects in function...
Read more >React: Stop checking if your component is mounted
This article will provide solutions to the “Can't perform a React state update on an unmounted component” warning and why a call to...
Read more >React setState usage and gotchas
setState () enqueues changes to the component state and tells React that this component and its children need to be re-rendered with the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After a quick look it looks to be that this line of code is the culprit
I’ve removed and it seems to be working so if you want a quick fix you can fork the repo and edit and use that fork or use something like patch-package.
I’m just wanting to do a few more tests before deploying.
Best
Edited: to remove the mentions of other issues as I believe you didn’t mean to do that but was just using a
#
which will reference an issue/pr.Confirmed as bug 😃