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.
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.
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 fieldsmapPropsToStore
andmapStoreToProps
.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.