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

Provide an innerRef prop #124

Merged
merged 1 commit into from Jan 11, 2019
Merged

Provide an innerRef prop #124

merged 1 commit into from Jan 11, 2019

Conversation

nbouscal
Copy link
Contributor

@nbouscal nbouscal commented Oct 15, 2018

This allows access to the underlying DOM wrapper node, which is useful if you need to call focus. In my use case I have several different HotKeys components on different parts of the page, and want to pass focus from one to another. They don't always have children with a tabindex, so there is no other element to add a ref to. Another option could be using state and the focused property, but in my testing the focused property doesn't really seem to work.

The innerRef pattern seems to be idiomatic, being used by e.g. react-router and formik.

Another option would be using ref forwarding, but that would be backwards-incompatible for anyone currently using refs to access the HotKeys component itself.

@greena13 greena13 merged commit cf98aaa into greena13:master Jan 11, 2019
@greena13
Copy link
Owner

I had to modify to match the new architecture (and add a sanity test), but the idea is now in master and will go out with the next release.

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.

None yet

2 participants