gaearon / gaearon/react-elmish-example

How would you pass actions up to the parent?

Open
#1 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
170
Forks
10
PR merge metrics
No merged PRs in 30d

Description

First off, very cool example.

I'm playing around with this pattern on a help form. The form has its typical onChange events that update the state, etc. But what happens when the form is submitted? How do I get that information up to the parent?

Right now I'm having to parse through all the action messages and delegate them to the project updater. This is pretty tedious.

``` jsx
let Help = {
view: function({state, dispatch}) {
return (
state.success ?
:

)
},
update: function(state=initialState, action) {
switch (action.type) {
case ON_ERROR:
//...
case VALIDATE_AND_SUBMIT:
//...
case ON_CHANGE:
return HelpForm.update(state, action)
default:
return state
}
}
}
```

It would be cool it there was a way to indicate whether an action is meant to be dispatched to itself, or up to the parent. How does Elm deal with this? I understand this is just a toy example, but its really cool and I think it would be really power if its done right.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no source file or test. Start by reading the example's existing JSX view and update/action flow shown in the report, then review the discussion for an agreed direction. Done would require a decided, documented way to distinguish actions handled by the component from actions passed to its parent, with tests or an example demonstrating that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.