Browse Source

docs(forwarding-refs.md): add warning to third-party library maintainers (#968)

* docs(forwarding-refs.md): add warning to third-party library maintainers

* Update forwarding-refs.md

* Update forwarding-refs.md

* Update forwarding-refs.md

* tweaks
main
Andy Edwards 7 years ago
committed by Dan Abramov
parent
commit
af3b37ece3
  1. 6
      content/docs/forwarding-refs.md

6
content/docs/forwarding-refs.md

@ -37,6 +37,12 @@ Here is a step-by-step explanation of what happens in the above example:
>
>Ref forwarding is not limited to DOM components. You can forward refs to class component instances, too.
## Note for component library maintainers
**When you start using `forwardRef` in a component library, you should treat it as a breaking change and release a new major version of your library.** This is because your library likely has an observably different behavior (such as what refs get assigned to, and what types are exported), and this can break apps and other libraries that depend on the old behavior.
Conditionally applying `React.forwardRef` when it exists is also not recommended for the same reasons: it changes how your library behaves and can break your users' apps when they upgrade React itself.
## Forwarding refs in higher-order components
This technique can also be particularly useful with [higher-order components](/docs/higher-order-components.html) (also known as HOCs). Let's start with an example HOC that logs component props to the console:

Loading…
Cancel
Save