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 solution for dealing with ref problem when using HOC #399

Merged
merged 7 commits into from
Dec 9, 2016
Merged

Provide solution for dealing with ref problem when using HOC #399

merged 7 commits into from
Dec 9, 2016

Conversation

aesopwolf
Copy link
Collaborator

Add method to expose the wrapped instance when using the HOC (higher order component)

It's ref's all the way down. This closes #308, closes #341

…order component)

It's `ref`'s all the way down. This closes #308, closes #341
@aesopwolf aesopwolf changed the title Provide solution to dealing with ref problem when using HOC Provide solution for dealing with ref problem when using HOC Oct 5, 2016
Copy link

@tjcampbell tjcampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nicely done! The only thing I could spot was a wonky camelCase on getWrappedInstance in the test description. Not a biggy but might help searchability :) Thanks for the PR @aesopwolf 👍

@aesopwolf
Copy link
Collaborator Author

pinging @christianalfoni do you need additional maintainers for this project?

@aesopwolf
Copy link
Collaborator Author

I came across a different approach that might be slightly better, which is to pass a prop called innerRef that takes a function just like the normal ref prop. A full example can be seen here styled-components/styled-components#122

What do you think @christianalfoni?

@aesopwolf
Copy link
Collaborator Author

@Semigradsky are you able to chime in here and help approve this?

@brianfegan
Copy link

Is there any movement on this? I'm seeing this as a blocker to being able to reset a multi checkbox group of checkbox inputs to their initial state. While this.refs.form.reset() will reset the overall form value to that initial state, the HOC wrapped checkboxes still remain checked.

@aesopwolf
Copy link
Collaborator Author

aesopwolf commented Nov 24, 2016 via email

@aesopwolf
Copy link
Collaborator Author

I pulled the trigger and forked the repo. I published it to npm under formsy (can't believe it was available!). I also merged in this PR to the new fork.

You can check it out here:

I think I'll make an issue to advertise the new fork and it's location.

@aesopwolf aesopwolf closed this Dec 8, 2016
@aesopwolf aesopwolf deleted the feature/getWrappedInstance branch December 8, 2016 00:36
@aesopwolf aesopwolf restored the feature/getWrappedInstance branch December 8, 2016 22:09
@aesopwolf
Copy link
Collaborator Author

I was given write access to the repo (see #411). So I'm going to reopen this PR and get it merged in.

@aesopwolf aesopwolf reopened this Dec 8, 2016
This reverts commit 667ac8c.
@aesopwolf aesopwolf merged commit 2b24911 into christianalfoni:master Dec 9, 2016
sdemjanenko added a commit to meraki/mki-formsy-react that referenced this pull request May 26, 2017
* christ/master:
  v0.19.2
  Revert "fix: show the default validation message when there is a required error (christianalfoni#386)"
  v0.19.1
  fix: show the default validation message when there is a required error (christianalfoni#386)
  Remove stray sentence. (christianalfoni#415)
  Update API.md
  Fix crash when comparing array with null (christianalfoni#404)
  docs: Removing unnecessary single quote (christianalfoni#410)
  0.19.0
  feat: expose inner element when using HOC (christianalfoni#399)
  Update README.md
  Update LICENSE
  Nit-picky typo
@aesopwolf aesopwolf deleted the feature/getWrappedInstance branch August 20, 2018 02:52
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.

Assign ref to formsy elements when using HOC or Decorator How to retrieve ref to input when HOC used
3 participants