Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created Jun 16, 2020
Embed
What would you like to do?
import React, { Component } from 'react';
import './App.css';
import { connect } from 'react-redux';
import { getPostByIdFunc, getPostsBulkFunc } from './actions';
class App extends Component {
render() {
console.log(this.props);
return (
<div className="App">
<button onClick={() => {
this.props.getPostById(1);
}}>By Id</button>
<button onClick={() => {
this.props.getPostBulk();
}}>In bulk</button>
</div>
);
}
}
const mapStateToProps = state => {
return {
state
};
}
const mapDispatchToProps = dispatch => {
return {
getPostById: getPostByIdFunc(dispatch),
getPostBulk: getPostsBulkFunc(dispatch)
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment