Universal Reactotron import for react-native and react-js
If you are writing universal app for both web and native, and wonder whether to import reactotron-react-native
or reactotron-react-js
, import reactotron-react
then.
Under the hood, reactotron-react
uses module import and file extensions to selectively import reactotron-react-native
or reactotron-react-js
based on the platform you are running on.
npm install --save-dev reactotron-react
# or yarn
yarn add reactotron-react
// instead of
import Reactotron from 'reactotron-react-js'
Reactotron
.configure() // we can use plugins here -- more on this later
.connect() // let's connect!
// or
import Reactotron from 'reactotron-react-native'
Reactotron
.configure() // controls connection & communication settings
.useReactNative() // add all built-in react native plugins
.connect() // let's connect!
// do
import Reactotron from 'reactotron-react'
Reactotron
.configure()
.useReactNative() // this will have no effect on react-js for web
.connect()
- To know more about Reactotron, see here
- To install Reactotron, see Installation guide
Watch this amazing talk leland richardson about writing universal react app for Android, iOS, web and more platforms.