This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const TEXT_CHANGED = 'text_changed'; | |
| export const TEXT_CHANGED_SUCCESS = 'text_changed_success'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createStore, compose, applyMiddleware } from 'redux'; | |
| import thunk from 'redux-thunk'; | |
| import { createLogger } from 'redux-logger'; | |
| import reducers from '../Reducers'; | |
| const middleWare = []; | |
| middleWare.push(thunk) | |
| const loggerMiddleware = createLogger({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| TEXT_CHANGED | |
| } from '../Actions/types'; | |
| /* Remember that TEXT_CHANGED should be defined and must have a value otherwise it | |
| will be undefined and no error would popup and in the reducer we will have a | |
| case of undefined | |
| case undefined: | |
| return ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { combineReducers } from 'redux'; | |
| import TextReducer from './TextReducer'; | |
| export default combineReducers({ | |
| // the keys here are going to be the property of state that we are producing. | |
| text_reducer: TextReducer | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const INITIAL_STATE = { | |
| text: '' | |
| }; | |
| export default ( state=INITIAL_STATE , action ) => { | |
| /* We always have the exact same format for every reducer we write, we always | |
| have a switch statement and depending on the action it will decide what to | |
| do with it. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| TEXT_CHANGED | |
| } from './types'; | |
| export const textChanged = (text) => { | |
| return { | |
| type: TEXT_CHANGED, | |
| payload: text | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default class CustomTextInput extends Component { | |
| onTextChange = (text) => { | |
| // Step-12 | |
| } | |
| render() { | |
| return ( | |
| <View | |
| style={{ flex: 1, justifyContent: 'center', alignItems: 'center'}} | |
| > | |
| <TextInput |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // In src/App.js | |
| import { Provider } from 'react-redux'; | |
| import store from './Store'; | |
| import CustomTextInput from './Components/CustomTextInput'; | |
| <Provider store={store}> | |
| <CustomTextInput/> | |
| </Provider> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { combineReducers } from 'redux'; | |
| export default combineReducers({ | |
| temp: () => {return {}} | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // store/index.js | |
| import { createStore, compose, applyMiddleware } from ‘redux’; | |
| import thunk from ‘redux-thunk’; | |
| const store = createStore({ | |
| reducers, | |
| {}, // default state of the application | |
| compose( | |
| applyMiddleware(thunk) | |
| ) |