Fix useEffect web component warnings#674
Conversation
|
|
|
…hub.com:RaspberryPiFoundation/editor-ui into issues/668-Fix_useEffect_web_component_warnings
|
|
| }, 2000); | ||
| setTimeoutId(id); | ||
| }, [project]); | ||
| }, [project, timeoutId, webComponent]); |
There was a problem hiding this comment.
Are you sure this doesn't make the browser go crazy? The reason the timeoutId was left out initially was because it was causing constant rerenders (which was throwing up a warning in the console)
There was a problem hiding this comment.
Will run it locally and see the console, thanks a lot for flagging it up
There was a problem hiding this comment.
@loiswells97 I wrapped the method to clear any existing timeout when the dependencies change. Could you please check the console if there are any issues? I couldn't replicate any console issue
There was a problem hiding this comment.
Okay, I took a look and I'm not sure the custom event is still being triggered. For example, if you go to the web component test page it should print the code to the console 2 seconds after it's changed (in response to the codeChanged event), but that isn't happening anymore.
There was a problem hiding this comment.
@loiswells97 I removed the reset of timeoutId. I wonder if adding a timeout clearing function (clearing interval) might be a good idea to include the timeoutId within the useEffect() dependencies and also make sure it's not causing any console issues.
There was a problem hiding this comment.
I think this is still behaving strangely because it now triggers the event multiple times (I think once for each key press) whereas it should only trigger once 2 seconds after the user stops typing
There was a problem hiding this comment.
On your point, I'm not sure, I feel like my understanding of the timeout stuff is sketchy at best
|
|
|
|
|
|
|
| const project = useSelector((state) => state.editor.project); | ||
| const codeRunTriggered = useSelector( | ||
| (state) => state.editor.codeRunTriggered, | ||
| (state) => state.editor.codeRunTriggered |
There was a problem hiding this comment.
I think this might have broken the linting?
CHANGELOG.md
Outdated
|
|
||
| ## Unreleased | ||
|
|
||
| ## [0.19.2] - 2023-10-10 |
There was a problem hiding this comment.
We normally only add this line when we cut a release, and leave all the current stuff under Unreleased
|
|
|
…hub.com:RaspberryPiFoundation/editor-ui into issues/668-Fix_useEffect_web_component_warnings
|
closes #668