feat(transform-hook): UseTransformComponent added #405
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.
Hook added to return an element, given the current state
Given that v3 introduces the dynamic where
useTransformEffect
is the only hook that has up to date state:https://github.com/prc5/react-zoom-pan-pinch/blob/c0871e27907c1e9338c613d1e5abfc98a873da52/CHANGELOG.md?plain=1#L5-L7
I wanted to suggest a new style of hook that could return an item, given the internal context.
The reason for this is the following pattern.
Currently if I want to write a component that uses state from inside the context I need to copy that state using
useTransformEffect
to another piece of state to use it like this:This works for what I am trying to do, but I have run into issues with synchronization and infinite loops when duplicating state like this.
The new hook I am proposing here should allow something like this:
This would remove the duplicated state and ensure that the same state being rendered on the page is the state coming from the context.
I can add docs, tests, and examples, but I wanted to see what the response from y'all was like before adding any of that.