Bugfix/media capabilities use effect #55
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.