Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs add title to local and global examples #299

Closed
2 tasks done
morewings opened this issue Mar 5, 2024 · 1 comment
Closed
2 tasks done

Improve docs add title to local and global examples #299

morewings opened this issue Mar 5, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation released

Comments

@morewings
Copy link
Owner

morewings commented Mar 5, 2024

  • add title to local and global examples
  • add note about useEffect to setVariable and setTheme

The reason this code isn’t correct is that it tries to do something with the DOM node during rendering. In React, rendering should be a pure calculation of JSX and should not contain side effects like modifying the DOM.
Moreover, when VideoPlayer is called for the first time, its DOM does not exist yet! There isn’t a DOM node yet to call play() or pause() on, because React doesn’t know what DOM to create until you return the JSX.

The solution here is to wrap the side effect with useEffect to move it out of the rendering calculation:
By wrapping the DOM update in an Effect, you let React update the screen first. Then your Effect runs.

When your VideoPlayer component renders (either the first time or if it re-renders), a few things will happen. First, React will update the screen, ensuring the

@morewings morewings added the documentation Improvements or additions to documentation label Mar 5, 2024
morewings pushed a commit that referenced this issue Apr 7, 2024
## [0.7.3](v0.7.2...v0.7.3) (2024-04-07)

### Bug Fixes

* **docs:** add license to package.json ([420ef80](420ef80)), closes [#297](#297)
* **docs:** improve code examples ([fa24edc](fa24edc)), closes [#299](#299)
@morewings
Copy link
Owner Author

🎉 This issue has been resolved in version 0.7.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation released
Projects
None yet
Development

No branches or pull requests

1 participant