React higher-order component (HOC) for ref forwarding
npm install react-with-forwarded-ref   
This React.js higher-order component
(HOC) exists to provide
an appropriate wrapper for components that utilize
forwarded refs. It accepts aref via props and renames ref to forwardedRef along
with whatever other props are passed in.
npm i react-with-forwarded-ref
`
or
`
yarn add react-with-forwarded-ref
`Usage
Let's say you have a react component named Comp:`js
// Comp.js fileconst Comp = ({ children, className }) => (
{children}
)export default Comp
`React.createRef()
and want to pass this ref to a child component, you need to utilize
forwarded refs. This component
handles all the hassle by using the higher-order component
(HOC) pattern to wrap
your component, accept the ref, and forward it to you as forwardedRef.`js
// Comp.js fileimport withForwardedRef from 'react-with-forwarded-ref'
const Comp = ({ children, className, forwardedRef }) => (
{children}
)export default withForwardedRef(Comp)
``Thanks goes to these wonderful people (emoji key):
Robert Pearce 💻 📖 💡 🤔 ⚠️ | Kristián Žuffa 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!