PudgePacket PudgePacket - 1 year ago 83
React JSX Question

Rendering platform agnostic wrapper in React

In a library I'm writing, there is a component which adds props to it's children then renders them. Because React only renders 1 element, the children have to be wrapped in something. Up until trying to port the library to React Native it was wrapping in a

. That doesn't work in React Native however.

Is there a platform agnostic wrapper that will automatically choose the correct one depending on platform? Or is there a way to write logic that will choose between
at runtime?

I don't want to write one for web and one for native with the only difference being
swapped for

Answer Source

View maps directly to the native view equivalent on whatever platform React is running on, whether that is a UIView, <div>, android.view, etc.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download