Skip to content

Instantly share code, notes, and snippets.

@Chalarangelo
Created October 30, 2017 21:10
Show Gist options
  • Save Chalarangelo/efddfae3d79289ae0845cd096fea1829 to your computer and use it in GitHub Desktop.
Save Chalarangelo/efddfae3d79289ae0845cd096fea1829 to your computer and use it in GitHub Desktop.
// React and other imports...
import { connect } from 'react-redux';
import { viewAll, searchPost } from './actions';
class App extends Component {
// Code for our App component...
}
// Mapping state to props
function mapStateToProps(state){
return {
posts: state
}
}
// Connecting the App component
export default connect(mapStateToProps, { viewAll, searchPost })(App);
// React and other imports...
import App from './App';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducer from './reducers';
import registerServiceWorker from './registerServiceWorker';
// Creating a store
const store = createStore(reducer);
// Wrapping our app inside a provider
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root'));
registerServiceWorker();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment