-
Notifications
You must be signed in to change notification settings - Fork 24
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
Dynamic component composition #46
Comments
Hello, you'd need to use Something like: // view
export default view(({ model, dispatch }) => (
<ul>
{model.list.map((item, index) =>
<li>
<Component model={{content: item}} dispatch={forwardTo(dispatch, 'Component', index)} />
</li>
)}
</ul>
));
// updater
import { Updater, Matchers } from 'redux-elm';
export default new Updater({ components: [] })
.case('Component', (model, action) => {
const numericComponentIndex = parseInt(action.matching.args.param, 10);
return {
...model,
components: model.components.map((componentModel, index) => {
if (index === numericComponentIndex) {
return componentUpdater(componentModel, action);
} else {
return componentModel;
}
})
};
}, Matchers.parameterizedMatcher) |
Thanks, @tomkis1! |
np! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, there!
Maybe I have a very stupid question but I can't understand how to make multiple components composition when the list of components is dynamically changes.
For example I have two components:
Component
it's view:
ComponentList
is's view:
it's updater:
It is totally clear for me. But what should I do, if I have dynamically changed component list. Eg:
How should my ComponentList updater look like?
The text was updated successfully, but these errors were encountered: