Skip to content

Instantly share code, notes, and snippets.

@rmcauley
Created October 26, 2018 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmcauley/437f947788786a3948e202952fb7703c to your computer and use it in GitHub Desktop.
Save rmcauley/437f947788786a3948e202952fb7703c to your computer and use it in GitHub Desktop.
function blah(props) {
return <div onClick={props.doThing}>{props.id}</div>
}
const mapStateToProps = state => ({id: state.thing.id});
const mapDispatchToProps = dispatch => ({
doThing: () => {
callMyApi('doThing', {iWantMappedProps.id});
},
});
@jgruppuso
Copy link

return <div onClick={() => props.doThing(state.thing.id)}>{props.id}</div>

@jgruppuso
Copy link

const mapDispatchToProps = dispatch => ({
  doThing: (thing) => {
     callMyApi('doThing', thing);
  },
});

@rmcauley
Copy link
Author

class Blah extends React.Component {
   doThing () {
      this.props.doThing(this.props.id)
   }

   you know the rest

@rmcauley
Copy link
Author

mapDispatchToProps = dispatch => {
  doThing: {
    return dispatch((localDispatch, getState) => {
       const mappedProps = mapStateToProps(getState());
    });
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment