Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass props in selectors #20

Closed
vasa-chi opened this issue Aug 6, 2015 · 12 comments
Closed

Can't pass props in selectors #20

vasa-chi opened this issue Aug 6, 2015 · 12 comments

Comments

@vasa-chi
Copy link

vasa-chi commented Aug 6, 2015

react-redux supports passing props to select. Currently reselect only passes state. Is it possible to add props to selector functions?

@ellbee
Copy link
Collaborator

ellbee commented Aug 6, 2015

I'm not sure that the new react-redux api for the connect decorator is going to support this. Check out this PR

@vasa-chi
Copy link
Author

vasa-chi commented Aug 7, 2015

Huh. That would be unfortunate... Maybe @gaearon can clarify?

@vasa-chi
Copy link
Author

vasa-chi commented Aug 7, 2015

Seems that there will be an additional argument for @connect decorator for using props to further filter the state. So I guess that yes, this api will get deprecated.

@ellbee
Copy link
Collaborator

ellbee commented Aug 7, 2015

Confirmed as gone in the release notes for react-redux v.0.5.0

@scottcorgan
Copy link

It looks like this added back in react-redux. Can we get it back in this package?

@ellbee
Copy link
Collaborator

ellbee commented Aug 19, 2015

Yep, I guess we should look into this now

@ellbee ellbee reopened this Aug 19, 2015
@scottcorgan
Copy link

Any time frame on this? Attempted to jump in on a fork, but didn't know if changes were coming soon for a 1.0.

@ellbee
Copy link
Collaborator

ellbee commented Aug 20, 2015

Funnily enough, I was just looking at it. Did you have a plan? I'm wondering how the dumb default memoize and its reference equality is going to work with the props. I don't recall how the props are handled inside react. I guess if the prop object is mutative and has a stable reference for the lifetime of the component or it is recreated entirely on each render then we might have problems?

I think that the API might change slightly in the next version, possibly allowing the user to specify a memoization function in createSelectorCreator and allowing variadic depencies. I just started exploring this in my fork here if you'd like to have a look.

@gaearon
Copy link

gaearon commented Aug 20, 2015

I guess if the prop object is mutative and has a stable reference for the lifetime of the component or it is recreated entirely on each render then we might have problems?

Props object is new every time. It's considered immutable.

@faassen
Copy link
Collaborator

faassen commented Aug 31, 2015

Okay, I just finally started using reselect in a project and ran into this one. So basically we want to parameterize the select expression with an additional object that should be passed down the select chain, right? And we should be able to express when we consider this object unchanged, so that we can make use of caching.

@ellbee
Copy link
Collaborator

ellbee commented Aug 31, 2015

Take a look at #35. We've had a bit of a discussion about this there

@ellbee
Copy link
Collaborator

ellbee commented Sep 9, 2015

Address in the 1.0.0 release

@ellbee ellbee closed this as completed Sep 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants