Fixed component double rendering in StrictMode #310
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Suggested merge commit message (convention)
Fix: Fixed component double rendering in StrictMode. Closes #294.
Additional information
It looks like this issue exists only in React v18+. React strict mode checks are run in development mode only. They do not impact the production build. For testing purposes we can use the
sample/index.html
.Checkout the
i/294
branch, bump React version inpackage.json
forreact
andreact-dom
to^18.0.0
and install dependencies.Load the development builds for React framework in the
sample/index.html
:Wrap the sample application in the
<React.StrictMode>
. Also, you need to change the way how the component is rendered in thesample/index.html
(as theReactDOM.render()
is no longer supported in React v18):Build the component:
yarn run develop
.Open the sample and make sure it is rendered only once. There should be no warnings or errors in the console. If you have React Developer Tools installed in your browser, in the Components tab there should be no red exclamation sign indicating that the app is not in strict mode (because it is).