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

Add deps/selector/keys argument to useContext #16292

Closed
syabro opened this issue Aug 5, 2019 · 2 comments
Closed

Add deps/selector/keys argument to useContext #16292

syabro opened this issue Aug 5, 2019 · 2 comments

Comments

@syabro
Copy link

syabro commented Aug 5, 2019

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
useContext triggers update if the whole passed store changed

What is the expected behavior?
add keys argument to trigger update only if specified keys in passed store changed

It would be useful to improve application speed.

F.e.

function MyComponent() {
  // example context value
  // I want to ignore age changes (who does't hehe)
  // {
  //   name: 'Max',
  //   age: 35
  // }
  // dep's-like style
  const {name} = useContext(MyContext, 'name')
  // or
  // comparator style 
  const {name} = useContext(MyContext, (current, old) => current.name !== old.name)
}
@vkurchatkin
Copy link

Duplicate of #14110

@syabro
Copy link
Author

syabro commented Aug 5, 2019

@vkurchatkin ty

@syabro syabro closed this as completed Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants