Change string refs in function component message#18031
Merged
sebmarkbage merged 1 commit intofacebook:masterfrom Feb 21, 2020
Merged
Change string refs in function component message#18031sebmarkbage merged 1 commit intofacebook:masterfrom
sebmarkbage merged 1 commit intofacebook:masterfrom
Conversation
This should refer to string refs specifically. The forwardRef part doesn't make any sense in this case. I think this was just an oversight.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit dbadcd6:
|
Contributor
|
Wait, don't you still need to wrap a function component with Edit: nvm, seems like that's just a different error altogether. |
ermanzohre
approved these changes
Feb 17, 2020
gaearon
reviewed
Feb 21, 2020
| "307": "Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)", | ||
| "308": "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().", | ||
| "309": "Function components cannot have refs. Did you mean to use React.forwardRef()?", | ||
| "309": "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref", |
Collaborator
There was a problem hiding this comment.
Should we update this doc to mention useRef?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This should refer to string refs specifically. The forwardRef part doesn't make any sense in this case. I think this was just an oversight. This case is when a string ref is used from a function component, not on a function component.