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

FindDOMNode is deprecated in StrictMode #475

Closed
tstirrat15 opened this issue Oct 21, 2019 · 1 comment · Fixed by #476
Closed

FindDOMNode is deprecated in StrictMode #475

tstirrat15 opened this issue Oct 21, 2019 · 1 comment · Fixed by #476

Comments

@tstirrat15
Copy link
Contributor

I suppose the first question is what onMounted supports. It seems like it breaks React abstractions to some degree. I wasn't able to find discussion on its genesis, either.

I've been working through fixing StrictMode issues in my own project, and findDOMNode in this library is one of the things it's complaining about. If onMounted is critical functionality, it should be implemented with refs. If it's not, can it be deprecated?

I'll submit a PR.

@frederickfogerty
Copy link
Contributor

frederickfogerty commented Oct 22, 2019

Ahhhh this is one from a while ago, but I believe the reason it was implemented was so that developers could hook into the root img tag and say, add a onLoad handler for their own use.

We could also probably use a ref here instead of a callback.

i.e. instead of this...

// In consuming code...
<Imgix
  onMounted={(img: HTMLImageElement) => {}}
/>

we support this...

// In consuming code...
<Imgix
  ref={(img: HTMLImageElement) => {}}
/>

This is imo more idiomatic React code these days.

This would also technically be a breaking change because ref would right now point to the instance of the Imgix component. My gut feeling is that 0.0001% of people would use the ref in this way, so the impact is minimal. The alternative is to call the ref prop something else, like htmlRef, which would not be a breaking change.

Leaving the rest up to you @sherwinski @jayeb

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

Successfully merging a pull request may close this issue.

2 participants