Skip to content

Support react-native (view-only) #363

Open
@Shaddix

Description

@Shaddix

It'd be great to support react-native!

Use case: web-based react-native designer, render the results (view-only) in react-native.

View-only mode (<Editor enabled={false}>) doesn't actually depend on anything dom-related, so it seems easy to make it work under react-native.

I tried it as a proof-of-concept, and it seems that there are only 2 things that needs to be changed:

  1. getRandomId should use nanoid/non-secure ('nanoid' doesn't work in react-native)
  2. RenderIndicator should import react-dom conditionally. Something like
const isReactNative =
  typeof window !== 'undefined' &&
  window.navigator &&
  window.navigator.product &&
  window.navigator.product === 'ReactNative';

const ReactDOM = !isReactNative ? require('react-dom') : null;

And that's it! After only these two changes it works on React-Native!

I could provide a PR if you are ok with the idea :)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions