Skip to content

Instantly share code, notes, and snippets.

@necolas
Last active October 28, 2023 12:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save necolas/6af06deeff559d85bb3b5baebb9558f1 to your computer and use it in GitHub Desktop.
Save necolas/6af06deeff559d85bb3b5baebb9558f1 to your computer and use it in GitHub Desktop.
/**
* This module is aliased to 'react-native' in our webpack config.
* RNW currently uses inline styles. Our existing CSS – written using `css-modules`
* and processed by `post-css` – needs to override RNW's default component styles
* when RNW is being used to render the app. A postcss transform was added to our
* webpack config to append `!important` to (almost) every CSS declaration.
*/
import findNodeHandle from 'react-native-web/dist/modules/findNodeHandle';
import I18nManager from 'react-native-web/dist/apis/I18nManager';
import ReactDOMText from './components/Text';
import ReactDOMView from './components/View';
import ReactNativeText from 'react-native-web/dist/components/Text';
import ReactNativeView from 'react-native-web/dist/components/View';
import { render } from 'react-dom';
import StyleSheet from 'react-native-web/dist/apis/StyleSheet';
const enabled = true; // this would be a feature switch to toggle between implementations
const Text = enabled ? ReactNativeText : ReactDOMText;
const View = enabled ? ReactNativeView : ReactDOMView;
const ReactNative = {
findNodeHandle,
render
};
export default ReactNative;
export { I18nManager, StyleSheet, Text, View };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment