-
Notifications
You must be signed in to change notification settings - Fork 0
Autobind state props. to component props #5
Comments
It looks like a good idea to reduce useless right-hand to left-hand shuffling when all is needed is forwarding of state properties. But... usually, a field will be stored as a node, with its default being the value, and various additional key/value pairs used to convey additional information. So should your suggested I suppose a discussion (face to face) will be needed to clarify your intent. |
face2face 👍 |
@SamLebarbare do you still see a need for this? |
Sometimes components need to bind more than one property from a state node. Idealy i need 2 fields (=2 nodes) for this component, because, if the icon change, the component must rerender, and if the text change it's the same battle. Actually we can't do that with the field property: So we are faced to make limitative choices on which property must be mapped behing the value received by the node. On simple component like I conclude we can't do multi-mapping with current API and components must expose only one dynamic property (using the value of the node). What about other keys/values on node ? they can't trigger a rerender if node generation is not updated ? |
@SamLebarbare - Nothing prevents you from implementing The render () {
const {state} = this.props;
const glyph = this.props.glyph || state.get ('icon');
const text = this.props.text || state.get ('value');
...
} However, on the current implementation, there is no support for producing anything else than |
We must fix a convention for state properties and component properties.
Ex:
<Comp errorText={this.read ('errorText')} />
Next we can inject transparently with something like :
<Comp {...state.readall ()} />
The text was updated successfully, but these errors were encountered: