Since React Native 0.4.3 you can read your local JSON file like this:
const customData = require('./customData.json');
and then access customData like a normal JS object.
----
import sample from '../dbstore/sample1.json'
const customData = require('./customData.json');
import sample from '../dbstore/sample1.json'
const reducer = (state = [], action) => {
switch (action.type) {
case 'split_string':
return action.payload.split('')
case 'add_character':
return [...state, action.payload]
default:
return state;
}
}
const store = Redux.createStore(reducer)
store.getState()
const action1 = {
type: 'split_string',
payload: 'abcd'
}
store.dispatch(action1)
store.getState()
const action2 = {
type: 'add_character',
payload: 'e'
}
store.dispatch(action2)
store.getState()
Output:
[]
{"type":"split_string","payload":"abcd"}
["a","b","c","d"]
{"type":"add_character","payload":"e"}
["a","b","c","d","e"]
react-native init AwesomeAppAppRegistry.registerComponent('Bananas', () => Bananas);AppRegistry.registerComponent('AwesomeApp', () => Bananas);react-native start (i.e. React Native Packager) server running either on another terminal or another tab of TMUX (if you are using TMUX).react-native run-ios for instance, it will establish a new packager server that registered for that specific application.ps aux | grep react-native
kill command (e.g. kill -9 [PID]). You should find the launchPackager.command app in macOS, not sure about the other operating systems.run-ios (or android) again. You should be able to see the new path after running the new packager server, e.g.:Looking for JS files in
/Users/afshin/Desktop/awesome-app
adb shell input text "RR"
adb shell command has many useful features many of which are described here:adb shell input keyevent 82
npm install eslint-plugin-react@6.10.3 eslint-plugin-jsx-a11y@2.2.3 eslint-plugin-import@1.16.0rm -rf ios/build react-native run-iosnpm start. Then in the first terminal window, run react-native run-ios./path/to/ReactNative/app1 instead of /path/to/React Native/app1.lsof -i :8081kill -9 <PID>react-native upgrade. You can also use react-native-git-upgrade to do this.react-native init ProjectName --version 0.44.2npm install prop-types --savereact-native init manager --version 0.34.1 npm install react-native-router-flux@3.35.0 --savereact-native init manager --version 0.34.1 npm install react-native-router-flux@3.35.0 --save