Add mapPropsToStore and mapStoreToProps to connect config object
- Dominant language
- JavaScript
- Stars
- 42
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Currently ylem's `connect` function takes a ViewModel and a Component, but it can also take a second argument which is a config object. Currently this config object only supports one field, `deriveUpdates`. We want to add support for two additional fields `mapPropsToStore` and `mapStoreToProps`.
__mapPropsToStore__
Should allow props to be renamed when they come into the store. Basically the user will pass in a function which maps the props appropriately.
default: `mapPropsToStore: (props) => ({ props })`
custom example: `mapPropsToStore: ({foo, ...rest}) => ({ bar: foo, ...rest })`
__mapStoreToProps__
Should allow fields in the store to be renamed when they get passed into the component as props. Basically the user will pass in a function which maps the store fields appropriately.
custom example: `mapStoreToProps: ({ props, onFoo }) => ({
...props,
onFoo,
})`
This one is particularly tricky because react checks to make sure that the props it passes into the component are the props the component received.
Contributor guide
Research direction
Start at ylem's connect function and inspect how its config object currently handles deriveUpdates. Trace how props enter the store and how store fields reach the component, then verify that mapPropsToStore and mapStoreToProps support the stated defaults and custom mappings without violating React's props checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100