question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add "ownProps" argument for stateToComputed/dispatchToActions

See original GitHub issue

This is something react-redux does. For us it might look like:

{{user-detail userId=567}}
const stateToComputed = (state, ownProps) => {
  return {
    user: getUserById(state, ownProps.userId)
  }
}

I think this should be simple to add. react-redux defines this argument as

the props passed to your component

so we’re not talking about all possible properties on the Ember Component, just what was passed to it, which Ember stores in attrs.

We can pass in attrs to the functions, and then listen to didUpdateAttrs

so connect would be something like


...

handleChange() {  // and also in init
  ...
  let props = stateToComputed(redux.getState(), this.attrs);
  ...
},

didUpdateAttrs() {
  this.handleChange();
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dustinfarriscommented, Dec 1, 2016

Unless someone sees something wrong with this, I will spin up a PR tomorrow.

0reactions
toranbcommented, Dec 6, 2016

@dustinfarris ah right on 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the use of the ownProps arg in mapStateToProps and ...
I see that the mapStateToProps and mapDispatchToProps function which are passed to the connect function in Redux take ownProps as a second argument....
Read more >
Connect: Extracting Data with mapStateToProps - React Redux
It should take a first argument called state , optionally a second argument called ownProps , and return a plain object containing the...
Read more >
Add state as the third parameter to mapDispatchToProps #237
So that I could do this: var ToggleFollowButton = ({toggleFollow}) => Toggle ; ToggleFollowButton = connect(null, (dispatch, ownProps, ...
Read more >
Defining and Using React Redux mapStateToProps Function
The first argument, which is state , has the entire Redux store state. ... Therefore, we should only add ownProps to the parameter...
Read more >
Mastering mergeProps in Redux - Peanut Butter JavaScript
it takes three arguments: ownProps – which contains all of the props passed into the component outside of the connect function; mapProps –...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found