Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* 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
You can’t perform that action at this time.