Skip to content

Instantly share code, notes, and snippets.

@AstralJohn
Last active March 19, 2020 16:37
Show Gist options
  • Select an option

  • Save AstralJohn/c4b6e0dc75634cd96e29d0c32a634f3d to your computer and use it in GitHub Desktop.

Select an option

Save AstralJohn/c4b6e0dc75634cd96e29d0c32a634f3d to your computer and use it in GitHub Desktop.
React Redux Setup With DevTools
import React from "react";
import { connect } from "react-redux";
// Import your actions from your action's index.js file
// import { action1, action2 } from '../actions'
const ExampleComponent = ({ stateKey1, stateKey2, action1, action2 }) => {
// alternatively, ExampleComponent = (props) => ....
// const {stateKey1, stateKey2, action1, action2} = props;
return <div>Example</div>;
};
const mapStateToProps = ({ stateKey1, stateKey2 }) => ({
stateKey1,
stateKey2
});
export default connect(mapStateToProps, {
// action1,
// action2
})(ExampleComponent);
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./components/App";
import { Provider } from "react-redux";
import store from "./store";
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById("root")
);
import { combineReducers } from "redux";
/*
* Create reducers inside your reducers directory
* Example: import alerts from "./alerts";
*/
export default combineReducers({
// alerts,
deleteMe: () => "Delete Me"
});
import rootReducer from "./reducers";
import thunk from "redux-thunk";
import { createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
const middleware = [thunk];
export default createStore(
rootReducer,
composeWithDevTools(applyMiddleware(...middleware))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment