React Native rendering support#1385
Conversation
|
@aleksivuorela is attempting to deploy a commit to the Puck Team on Vercel. A member of the Team first needs to authorize it. |
|
Hello @aleksivuorela! Thank you very much for your contribution 🙏 We usually prefer having a feature request or bug report before opening a PR. This helps us understand the use case and agree on the best approach before implementation. You'll also have the full context, and we’ll be better prepared to review your changes. You can read more about our process in the Contributing Guide. All this means, it might take us a bit longer to review and decide how to move forward with this PR, and we might have some review comments that are higher level before going through implemention details. |
There was a problem hiding this comment.
@aleksivuorela thanks for this great contribution! This is smart, but I'm not sure it's quite the right API.
We've been discussing this over here: #965
Instead of using a single override for all slots (you're calling this div), we're exploring slot-specific render overrides, refs, and other options.
I don't think we're quite ready to merge this until the conversation has matured on that side.
Edit: I've just opened #1418. I think your PR would work in congruence if you can rename the div override to slot.
@chrisvxd I've renamed the override to Basically it allows overriding all the default divs via config at once, for example in React Native context where divs aren't available. |
| >; | ||
| }; | ||
| root?: RootConfigInternal<RootProps, UserField>; | ||
| overrides?: RenderOverrides; |
There was a problem hiding this comment.
This change doesn't seem necessary
There was a problem hiding this comment.
It is necessary – render overrides is provided via the config object. That way both <Puck> and <Render> use the same overrides as they share the config. I suppose the correct place for documentation would be here.
Perhaps the prop should be renamed e.g. renderOverrides so it's not confused with editor overrides.
We would like to use Puck in React Native project that uses react-native-web. Requirements were that editor works on web only, but rendering the JSON with
<Render>should work cross-platform.Issue is that internally Puck renders
<div>elements that do not work on native platforms. This was solved by addingoverridesto config for rendering div – similar to how you can already override parts of the editor UI.Now divs can be replaced with
<View>on native platforms by providing config like this to<Render>Another issue that caused app to crash on native platforms when importing anything from
@measured/puckwas inbubble-pointer-events.tswhich tried to useEventinterface, but it's not defined in native environment. This interface was simply shimmed to prevent crash since I believe it's relevant for editor only.These changes allowed us to use Puck in our React Native project successfully.