react-native-code-switch
v1.0.2
Published
A command line script that will comment and uncomment imports so you can use react and react-native components interchangeably.
Downloads
2
Maintainers
Readme
react-native-switch
A tool for switching between react and react-native components.
Getting Started
Install
yarn add react-native-code-switch
or
npm install react-native-code-switch
then in your package.json
file add this to the "scripts" block.
"switch":"node ./node_modules/react-native-code-switch/index.js"
How to use
Add a comment above the import you would like to toggle between web and mobile.
The following example will activate code for web:
// @switch web
import "styles.css"
And this code will activate code for mobile devices:
// @switch mobile
import "react-native-component-that-will-break-on-web"
Run yarn switch web
to activate the // @switch web
code.
Run yarn switch mobile
to activate the // @switch mobile
code.
The import line of code will be commented out when switch is not on it's platform.