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

chore: refactored from findDOMNode to refs #476

Merged
merged 7 commits into from
Oct 24, 2019

Conversation

tstirrat15
Copy link
Contributor

Fixes #475

Description

findDOMNode is deprecated in StrictMode. It's recommended against in the official docs, and if the functionality that it enables is required, refs are a good way of addressing the problem.

This PR refactors away from findDOMNode towards refs.

Changes

  • Refactor react-imgix components to use refs in favor of findDOMNode
  • Refactor tests to use mount instead of shallow, since shallow doesn't create or use refs
  • Remove a test function that wasn't in use

Steps to Test

See that the refactored tests are sane and passing.

Note

I wasn't quite sure what sort of work this represented (fix/feature/chore). Please let me know if a different designation is more appropriate.

@commit-lint
Copy link

commit-lint bot commented Oct 21, 2019

Styles

Contributors

@tstirrat15, @sherwinski

@frederickfogerty
Copy link
Contributor

frederickfogerty commented Oct 21, 2019

FYI @sherwinski @jayeb this is technically a breaking change since this would break support for React <16.3 (this library currently supports React 16.0, 16.1, and 16.2). If support for these versions is desired, then callback refs can be used source.

@tstirrat15
Copy link
Contributor Author

Good point. I can refactor towards a callback ref if that'd be preferable.

@frederickfogerty
Copy link
Contributor

Thanks for the reply @tstirrat15. @sherwinski and @jayeb will reply here soon with a strategy 👍. Thanks for the PR btw 🙌

@frederickfogerty frederickfogerty changed the title (chore): refactored from findDOMNode to refs chore: refactored from findDOMNode to refs Oct 22, 2019
Copy link
Contributor

@sherwinski sherwinski left a comment

Choose a reason for hiding this comment

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

Sorry for the hold up @tstirrat15, and thanks for looking into this! I am going to err on the side of providing wider support and say that we should use callback refs here.

@tstirrat15
Copy link
Contributor Author

Done

Copy link
Contributor

@sherwinski sherwinski left a comment

Choose a reason for hiding this comment

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

Awesome, thank you 🙌
I'm seeing some style changes when I run npm run pretty locally. Usually Prettier would auto fix this but it hasn't been working for some time it seems. I'm going to go ahead and commit those changes on top of what you already have and then this is good to go!

@sherwinski sherwinski merged commit db3a1d7 into imgix:master Oct 24, 2019
@frederickfogerty
Copy link
Contributor

👏 👏 👏

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.

FindDOMNode is deprecated in StrictMode
3 participants