feat(package/react): Add react-native support #2299
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.
I tried using gqty in react-native and ran into the issue that there are dependency pointing to react-dom, leading to an issue with the metro bundler pulling web resources. There where two dependencies that pull in react-dom, the hooks from
@react-hookz/web
and the ssr implementation usingreact-dom/server
.This PR introduces react-native support for @gqty/react. I did the following updates:
@react-hookz/web
with local hook helpers via hooks.ts (useRerender, useUpdateEffect, etc.) to avoid the peer dependency on react-dom. No behavioural change, just implementation detail. May need more testing.There are some risks in this approach as far as I can tell the removal of the wildcard could be a problem and would break anyone using
@gqty/react/*
imports. Also the custom implementation of the hooks maybe a risk.As an alternative I could also create a new
@gqty/react-native
package in order to keep the react package as is. There is some code duplication of course, it maybe possible to move certain things into a shared package but will take more time.