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

BrowserOnly causes React error #3144

Closed
ianschmitz opened this issue Jul 28, 2020 · 1 comment · Fixed by #3149
Closed

BrowserOnly causes React error #3144

ianschmitz opened this issue Jul 28, 2020 · 1 comment · Fixed by #3149
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@ianschmitz
Copy link

🐛 Bug Report

The BrowserOnly component returns undefined instead of null, which causes React to throw an error during a production build:

Error: Minified React error #152; visit https://reactjs.org/docs/error-decoder.html?invariant=152&args[]=BrowserOnly for the full message or use the non-minified dev environment for full errors and additional helpful warnings.Error: Minified React error #152; visit https://reactjs.org/docs/error-decoder.html?invariant=152&args[]=BrowserOnly for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

This was changed in #2976.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

Use BrowserOnly as suggested:

<BrowserOnly>{() => <Foo {...props} />}</BrowserOnly>

and run a production build of docusaurus.

Your Environment

  • Docusaurus version used: 2.0.0-alpha.59
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node 12.18.0
  • Operating system and version (desktop or mobile): macOS 10.15.6
@ianschmitz ianschmitz added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jul 28, 2020
@ianschmitz ianschmitz changed the title BrowserOnly returns undefined BrowserOnly throws React error Jul 28, 2020
@ianschmitz ianschmitz changed the title BrowserOnly throws React error BrowserOnly causes React error Jul 28, 2020
@slorber
Copy link
Collaborator

slorber commented Jul 28, 2020

Thanks, totally agree: #3149

@slorber slorber linked a pull request Jul 28, 2020 that will close this issue
@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants