I have a state that I want to map to my component: cache
.
const component = connect(state => ({ ...searchState(state), ...cache(state) }),
mapDispatchToProps)(App);
However, cache contains a lot of necessary properties I dont want.
I only want to map foo
to my App.
I've tried the following but foo
doesn't appear to get mapped.
const component = connect(state => ({ ...searchState(state), ...cache(state).foo }),
mapDispatchToProps)(App);
Is there some handy ES6 or ES7 magic I can use to strip out that single property and omit the rest?
Thanks.
Skip the spread, and assign to a property:
const component = connect(state => ({ ...searchState(state), foo: cache(state).foo }),
mapDispatchToProps)(App);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.