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

Bugfix/media capabilities use effect #55

Conversation

anton-karlovskiy
Copy link
Contributor

@anton-karlovskiy anton-karlovskiy commented Mar 20, 2020

Not ready to be merged yet.

One thing I'm concerned about is #52 (comment).
I think it could be a pitfall if we just passed empty array as dependencies to useEffect hook.
Let me try and take an example. We can imagine that we had a switch component as we have in our loading patterns tool project.
With it we were planning to test several media MediaDecodingConfigurations by switching them.
Probably we would change local component state with useState when switching and passed that changed local state to useMediaCapabilitiesDecodingInfo as the first argument.
But useMediaCapabilitiesDecodingInfo would work on mounting but not on re-rendering because it would be executed just once on mounting and not on re-rendering due to empty array as dependencies.
Probably some warnings are expected due to missing dependencies in useEffect hook as well.
That's why I suggested passing dependencies properly.

@anton-karlovskiy
Copy link
Contributor Author

@addyosmani

I've finished cleaning useMediaCapabilitiesDecodingInfo hook and fixing its unit tests.
It's ready for review.

@addyosmani addyosmani merged commit 1b5b5cf into GoogleChromeLabs:master Mar 27, 2020
@anton-karlovskiy anton-karlovskiy deleted the bugfix/media-capabilities-use-effect branch March 27, 2020 00:35
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.

2 participants