idibidiart / react-native-responsive-grid

Bringing the Web's Responsive Design to React Native
Other
379 stars 42 forks source link

Uncaught TypeError: e.persist is not a function #33

Closed geminiyellow closed 6 years ago

geminiyellow commented 6 years ago

@idibidiart hi,

i want to use it with react-native-web, but looks like have same error when render children.

Grid.js:47 Uncaught TypeError: e.persist is not a function
    at onLayout (Grid.js:47)
    at index.js:131
    at index.js:41

in here : https://github.com/idibidiart/react-native-responsive-grid/blob/1a9fdd10bf871fb8fb5314783ebd8c88650b27ed/src/components/Grid.js#L47

and i check the react-native docs,

https://facebook.github.io/react-native/docs/view.html#onlayout

{nativeEvent: { layout: {x, y, width, height}}}

on persist here.

could you tell me why use this func?

idibidiart commented 6 years ago

Try React Native DOM instead?

React Native Web is not fully compatible with React Native.

idibidiart commented 6 years ago

The RN docs cover event.persist. It's for retaining reference to the event after the handler has executed. As when you're referencing it asynchronously in e.g. InteractionManager.runAfterInteractions

geminiyellow commented 6 years ago

@idibidiart thanks for you reply,

i dont want to use React Native DOM, because it still has a big WARNING.

if i want to use your lib in rn4w, how to fix this?

idibidiart commented 6 years ago

Probably just remove e.persist() but no guarantee that anything will work. The Web and RN environments are very different. Does RNW even have InteractionManager API? if not, maybe use requestIdleCallback()

No idea. There is really no intent to support RNW.

peacechen commented 6 years ago

I'd be curious how this could be hooked up to RNW, but as idibidiart mentioned, the event callbacks in the web world are very different from RN. I believe persist() relies on the Yoga layout engine which react-native-dom has implemented in WebAssembly. Someone would need to map the web DOM event callbacks to the equivalent RN analogues, but not sure if that's feasible.

geminiyellow commented 6 years ago

ok, give up use this library. thanks your great work.

peacechen commented 6 years ago

@idibidiart I'm taking another look at react-native-web since progress on react-native-dom has stalled. How feasible do you feel it would be to shim this for use with react-native-web ?

idibidiart commented 6 years ago

@peacechen

I've never worked with RNW but things like runAfterInteraction etc don't exist in the browser although they can be replaced with things like requestIdleCallback....

I've been working on something completely different so I don't know if I'll ever get back to RN and it looks like Flutter is gaining ground and has better behavior on Android

Sorry I couldn't be of more help