react-native-portal icon indicating copy to clipboard operation
react-native-portal copied to clipboard

Use contextBridge?

Open natew opened this issue 2 years ago • 7 comments

Found this: https://github.com/pmndrs/its-fine#usecontextbridge

Think we could make this work with this library to avoid the context clearing issue? I could try out a PR

natew avatar Jun 23 '23 18:06 natew

good suggestion, i will look into , but feel free to submit a CR and i'll look into it this weekend

gorhom avatar Jun 23 '23 19:06 gorhom

@natew thanks for the suggestion, the library seemed to expose the internal contexts, but there is something wrong with passing values

https://github.com/gorhom/react-native-portal/assets/4061838/0e8f371d-0476-4e33-85db-dae7a404ad14

gorhom avatar Sep 16 '23 11:09 gorhom

i think i found the issue with the memoized bridge that it returns https://github.com/pmndrs/its-fine/blob/main/src/index.tsx#L221-L233 the equality check does not run a deep equality check which causes the return memoized value to be static and never change.

gorhom avatar Sep 16 '23 12:09 gorhom

I found this library while making a RN modal component. I noticed that its implementation method is very similar to my library react-activation(implements Vue keep alive in React).

Due to the movement of the virtual DOM, they both encountered the problem of context discontinuity. The approach of react-activation to this problem is to leave a consumer that listens to the context at the position of transferring the virtual DOM, and transfer all captured context content along with the virtual DOM to the outside. At the position of rendering the virtual DOM, the provider is rebuilt based on the captured context content.

This approach seems to have similarities with useContextBridge, hoping it could be of some help to this library.

CJY0208 avatar Sep 17 '23 07:09 CJY0208