Redux initial setup

This commit is contained in:
Sofiya Tepikin
2019-07-31 13:39:49 +02:00
parent 2d1ab273a0
commit 216a9044cd
4 changed files with 163 additions and 9 deletions
+22 -9
View File
@@ -9,6 +9,18 @@ import PasswordPrompt from './password-prompt'
import License from './license'
import AppLoadingView from './app-loading'
import { combineReducers } from 'redux'
import { configureStore } from 'redux-starter-kit'
import { Provider } from 'react-redux'
import dateReducer from '../slices/date'
const rootReducer = combineReducers({
dateReducer,
})
const store = configureStore({ reducer: rootReducer })
export default class AppWrapper extends Component {
constructor() {
super()
@@ -69,18 +81,19 @@ export default class AppWrapper extends Component {
shouldShowApp,
} = this.state
let initialView = null
if (isCheckingLicenseAgreement) {
return <AppLoadingView />
initialView = <AppLoadingView />
} else if (shouldShowLicenseAgreement) {
initialView = <License setLicense={this.disableShowLicenseAgreement}/>
} else if (shouldShowPasswordPrompt) {
initialView = <PasswordPrompt enableShowApp={this.enableShowApp} />
} else if (shouldShowApp) {
initialView = <App />
}
if (shouldShowLicenseAgreement) {
return <License setLicense={this.disableShowLicenseAgreement}/>
}
return <Provider store={store}>{initialView}</Provider>
if (shouldShowPasswordPrompt) {
return <PasswordPrompt enableShowApp={this.enableShowApp} />
}
return shouldShowApp && <App />
}
}
+120
View File
@@ -2122,6 +2122,11 @@
"strip-bom": "^2.0.0"
}
},
"curriable": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/curriable/-/curriable-1.3.0.tgz",
"integrity": "sha512-7kfjDPRSF+pguU0TlfSFBMCd8XlmF29ZAiXcq/zaN4LhZvWdvV0Y72AvaWFqInXZG9Yg1kA1UMkpE9lFBKMpQA=="
},
"dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
@@ -3369,6 +3374,11 @@
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ="
},
"fast-equals": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-1.6.3.tgz",
"integrity": "sha512-4WKW0AL5+WEqO0zWavAfYGY1qwLsBgE//DN4TTcVEN2UlINgkv9b3vm2iHicoenWKSX9mKWmGOsU/iI5IST7pQ=="
},
"fast-json-stable-stringify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
@@ -4381,6 +4391,14 @@
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
"dev": true
},
"hoist-non-react-statics": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz",
"integrity": "sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==",
"requires": {
"react-is": "^16.7.0"
}
},
"hosted-git-info": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz",
@@ -4473,6 +4491,14 @@
"safer-buffer": ">= 2.1.2 < 3"
}
},
"identitate": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/identitate/-/identitate-1.0.1.tgz",
"integrity": "sha512-xnDJ0JYhiZjBDuJRKbHoVzj5yP9FhATxLyUYswQyPdnJrwzGVBqS6DOmvKJi1lk7P+4dkL+hhUhuOZIcOUtG5A==",
"requires": {
"pathington": "^1.0.1"
}
},
"ieee754": {
"version": "1.1.13",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
@@ -4497,6 +4523,11 @@
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.6.3.tgz",
"integrity": "sha512-47xSUiQioGaB96nqtp5/q55m0aBQSQdyIloMOc/x+QVTDZLNmXE892IIDrJ0hM1A5vcNUDD5tDffkSP5lCaIIA=="
},
"immer": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/immer/-/immer-2.1.5.tgz",
"integrity": "sha512-xyjQyTBYIeiz6jd02Hg12jV+9QISwF1crLcwTlzHpWH4e0ryNWj1kacpTwimK3bJV5NKKXw458G2vpqoB/inFA=="
},
"import-fresh": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz",
@@ -6605,6 +6636,11 @@
"pify": "^2.0.0"
}
},
"pathington": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/pathington/-/pathington-1.1.7.tgz",
"integrity": "sha512-JxzhUzagDfNIOm4qqwQqP3rWeo7rNNOfIahy4n+3GTEdwXLqw5cJHUR0soSopQtNEv763lzxb6eA2xBllpR8zw=="
},
"pathval": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz",
@@ -7492,6 +7528,19 @@
"react-deep-force-update": "^1.0.0"
}
},
"react-redux": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-6.0.1.tgz",
"integrity": "sha512-T52I52Kxhbqy/6TEfBv85rQSDz6+Y28V/pf52vDWs1YRXG19mcFOGfHnY2HsNFHyhP+ST34Aih98fvt6tqwVcQ==",
"requires": {
"@babel/runtime": "^7.3.1",
"hoist-non-react-statics": "^3.3.0",
"invariant": "^2.2.4",
"loose-envify": "^1.4.0",
"prop-types": "^15.7.2",
"react-is": "^16.8.2"
}
},
"react-transform-hmr": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/react-transform-hmr/-/react-transform-hmr-1.0.4.tgz",
@@ -7599,6 +7648,47 @@
}
}
},
"redux": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/redux/-/redux-4.0.4.tgz",
"integrity": "sha512-vKv4WdiJxOWKxK0yRoaK3Y4pxxB0ilzVx6dszU2W8wLxlb2yikRph4iV/ymtdJ6ZxpBLFbyrxklnT5yBbQSl3Q==",
"requires": {
"loose-envify": "^1.4.0",
"symbol-observable": "^1.2.0"
}
},
"redux-devtools-extension": {
"version": "2.13.8",
"resolved": "https://registry.npmjs.org/redux-devtools-extension/-/redux-devtools-extension-2.13.8.tgz",
"integrity": "sha512-8qlpooP2QqPtZHQZRhx3x3OP5skEV1py/zUdMY28WNAocbafxdG2tRD1MWE7sp8obGMNYuLWanhhQ7EQvT1FBg=="
},
"redux-immutable-state-invariant": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/redux-immutable-state-invariant/-/redux-immutable-state-invariant-2.1.0.tgz",
"integrity": "sha512-3czbDKs35FwiBRsx/3KabUk5zSOoTXC+cgVofGkpBNv3jQcqIe5JrHcF5AmVt7B/4hyJ8MijBIpCJ8cife6yJg==",
"requires": {
"invariant": "^2.1.0",
"json-stringify-safe": "^5.0.1"
}
},
"redux-starter-kit": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/redux-starter-kit/-/redux-starter-kit-0.6.3.tgz",
"integrity": "sha512-A+7UjgmFrWdKksHl8xTGxDw6Bv8QJ+wrTubBscFNs5gIezGHOdwjqTTSVX4xMgQkgPtVfSPj/Bo+5o6f71/eTA==",
"requires": {
"immer": "^2.1.5",
"redux": "^4.0.0",
"redux-devtools-extension": "^2.13.8",
"redux-immutable-state-invariant": "^2.1.0",
"redux-thunk": "^2.2.0",
"selectorator": "^4.0.3"
}
},
"redux-thunk": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.3.0.tgz",
"integrity": "sha512-km6dclyFnmcvxhAcrQV2AkZmPQjzPDjgVlQtR0EQjxZPyJ0BnMf3in1ryuR8A2qU0HldVRfxYXbFSKlI3N7Slw=="
},
"regenerate": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz",
@@ -7808,6 +7898,11 @@
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"reselect": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/reselect/-/reselect-4.0.0.tgz",
"integrity": "sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA=="
},
"resolve": {
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz",
@@ -8241,6 +8336,17 @@
}
}
},
"selectorator": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/selectorator/-/selectorator-4.0.3.tgz",
"integrity": "sha512-A8+paRhzTab4Qm/38RAVnCgEZFbpn5xIWLyTCDqvyU3Obhmo94RS6UK1H00bVH7+U609sOhqbFJha09POsWURA==",
"requires": {
"fast-equals": "^1.2.1",
"identitate": "^1.0.0",
"reselect": "^4.0.0",
"unchanged": "^2.0.1"
}
},
"semver": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
@@ -8755,6 +8861,11 @@
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
},
"symbol-observable": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="
},
"sympto": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/sympto/-/sympto-1.0.4.tgz",
@@ -9245,6 +9356,15 @@
"through": "^2.3.8"
}
},
"unchanged": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/unchanged/-/unchanged-2.2.0.tgz",
"integrity": "sha512-L+MJNfyvFZkjw9WYRbmZBnYncBoASRNxE9eCm5SZWc2whdw19tPVigjJXNwu+/O+nCwp1kYYT8LX+jNuJakF9w==",
"requires": {
"curriable": "^1.3.0",
"pathington": "^1.1.7"
}
},
"unherit": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.1.tgz",
+3
View File
@@ -46,6 +46,9 @@
"react-native-share": "^1.1.3",
"react-native-vector-icons": "^6.4.2",
"realm": "^2.22.0",
"react-redux": "^6.0.0",
"redux": "^4.0.1",
"redux-starter-kit": "^0.6.3",
"sympto": "^1.0.4"
},
"devDependencies": {
+18
View File
@@ -0,0 +1,18 @@
import { createSlice } from 'redux-starter-kit'
const dateSlice = createSlice({
slice: 'date',
initialState: null,
reducers: {
setDate: (state, action) => action.payload
}
})
// Extract the action creators object and the reducer
const { actions, reducer, selectors } = dateSlice
// Extract and export each action creator by name
export const { setDate } = actions
export const { getDate } = selectors
export default reducer