Introduction to redux for react native

export const addPost = post => { return { type: ADD_POST, payload: post }; };
export const ADD_POST = 'ADD_POST;
import { Provider } from ‘react-redux’; Import configureStore from ‘./store/configureStore’; const store = configureStore(); <Provider store={store}> <App /> </Provider> AppRegistry.registerComponent("MyAPP", () => RNRedux);
import { createStore, combineReducers } from "redux"; import postReducer from "./reducers/posts"; const rootReducer = combineReducers({ posts: postReducer }); const configureStore = () = { return createStore(rootReducer); } export default configureStore;
import { connect } from "react-redux";
export default connect(mapStateToProps, mapDispatchToProps)(App);<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>const mapStateToProps = state => { return { posts: state.posts.posts }; };<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span><span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>
const mapDispatchToProps = dispatch => { return { onAddPost: (post) => dispatch(addPost(post)), }; };



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
2Hats Logic Solutions

2Hats Logic Solutions

2Hats Logic is a technology service company provide customized web and mobile application development.