oncreate not firing and actions not updating state with dynamic views
See original GitHub issueHello,
I am trying to set up a sort of state-based routing with hyperapp, with the following general architecture to create dynamic views:
const switchView = (state, actions) => {
if (!state.auth.token) {
return <Login
state={state.auth}
actions={actions.auth}
/>
}
if (!state.game.game_id) {
return <Lobby
state={state.game}
actions={actions.game}
/>
}
}
const view = (state, actions) => (
<div>
{switchView(state, actions)}
</div>
);
app(state, actions, view, document.querySelector('#container'));
Everything on the Login view works as expected, and it switches to the Lobby view as soon as an auth token is attached to state.auth as expected.
Once it reaches the Lobby, view, though, things start to fall apart. oncreate handlers never fire, and although console.logging state and actions shows that all the expected data and functions are present, executing the actions has no effect on the state. I have placed console.logs to determine that the actions are indeed running, they are just not updating state.
Is there something about my architecture that is causing this break? Or is there some other issue?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
onCreate() gets called when reopen from recent task after ...
Thus it is throwing Exceptions. It seems like the app process is killed when permission is changed and thus Activity is recreated.
Read more >The activity lifecycle | Android Developers
Your activity does not reside in the Created state. After the onCreate() method finishes execution, the activity enters the Started state, ...
Read more >Creating and Using Fragments | CodePath Android Cliffnotes
Overview. A fragment is a reusable class implementing a portion of an activity. A Fragment typically defines a part of a user interface....
Read more >Realtime Database triggers | Cloud Functions for Firebase
When handling a Realtime Database event, the data object returned is a DataSnapshot . For onWrite or onUpdate events, the first parameter is...
Read more >OnInit - Angular
A lifecycle hook that is called after Angular has initialized all data-bound properties of a directive. Define an ngOnInit() method to handle any...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@hartbeatnt what you are seeing is expected behavior due to Hyperapp using immutable state updates.
If you wish to log state updates to the
console
, we do have an official@hyperapp/logger
package you might want to try 😊 🔌Or if you want to log the state on every update you can do this in the view: