-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Code snippet in docs unexpectedly throws #11221
Comments
I'd be happy to update the docs. You (or I) should open an issue on https://github.com/reactjs/reactjs.org instead. |
Yes, please file the website issues in that repo. |
4 tasks
This ended up as a new issue in another repo: reactjs/react.dev#173 |
This was referenced Aug 7, 2020
This was referenced Sep 27, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
The docs present an example code snippet which crashes the js process. See https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element
In particular, notice the highlighted parts of the code snippet and the first sentence under the snipppet, which reads "React will call the ref callback with the DOM element when the component mounts, and call it with null when it unmounts.".
this.textInput = null;
.focusTextInput
method will dothis.textInput.focus();
.this.textInput
is null, it's really doingthis.null.focus();
.focus
is not a method ofnull
, so this will throwI would suggest adding a little guard for this in the code snippet so that people can copy-paste without worry, replacing this:
with this:
or something like this.
This was found in the docs for React v16.0.0
The text was updated successfully, but these errors were encountered: