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

Document createRef and forwardRef usage #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adrienharnay
Copy link

Fixes #72

@piotrwitek
Copy link
Owner

Hey @adrienharnay.
Thanks for your contribution. Could you please check the contributing.md guide.

One note, this PR doesn't fix #72 entirely, it would be great to include some React component example. Examples from react docs are preferred: https://reactjs.org/docs/forwarding-refs.html

const FancyButton = React.forwardRef((props, ref) => (
  <button ref={ref} className="FancyButton">
    {props.children}
  </button>
));

// You can now get a ref directly to the DOM button:
const ref = React.createRef();
<FancyButton ref={ref}>Click me!</FancyButton>;

The best place to put it would be in the stateless components section:

@artyomtrityak
Copy link

artyomtrityak commented Mar 23, 2019

That is not super clear how to use forwardRef with 16.8 react.
I am using const Component = (props: IProps, ref?: React.Ref<HTMLDivElement>) => {...} .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to use forwardRef?
3 participants