oncreate and conditionals
See original GitHub issueif i’m doing that:
const Panel = (prop, children) => (
<section oncreate={element => console.log('created', prop.id)}>
{children}
{prop.current && ' (active)'}
</section>
)
const state = {
panels: Array.from(new Array(10), (val, index) => index + 1),
currentPanel: 1
}
const actions = {
prevPanel: () => state => ({
currentPanel: state.currentPanel > 0 ? state.currentPanel - 1 : 0
}),
nextPanel: () => state => ({
currentPanel: state.currentPanel < state.panels.length - 1 ? state.currentPanel + 1 : state.panels.length - 1
})
}
const view = (state, actions) => (
<div>
<button onclick={actions.prevPanel}>
Prev
</button>
<button onclick={actions.nextPanel}>
Next
</button>
<div>
{state.panels.map((v, i) => (
<Panel id={i} current={i === state.currentPanel}>
This is Panel {v}
</Panel>
))}
</div>
</div>
)
app(state, actions, view, root)
everything works as expected and i get a couple of “created x” at my console log
but if i’m changing to this, to render only the active panel:
const Panel = (prop, children) =>
prop.current && (
<section oncreate={element => console.log('created', prop.id)}>
{children}
</section>
)
now i get one console log for the first element, then if i change state.currentPanel the app works as expected but without triggering the oncreate… so no further console line!
any ideas?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
What do you write in conditionals when there are doubles
What do you write in conditionals when there are doubles ... onCreate(savedInstanceState); setContentView(R.layout.activity_kalkulator); ...
Read more >Conditional navigation - Android Developers
When designing navigation for your app, you might want to navigate to one destination versus another based on conditional logic.
Read more >Functions in Android (1 hour) - Hack Pacific (@hackpacific)
... Variables: Exercises (1 hour) · Conditionals (2 hours) · Conditionals: Exercises (1 hour) ... onCreate looks a lot like functions we've seen...
Read more >Android Tutorial for Beginners 6 # Android Activity Lifecycle ...
(onStop) □ If it is garbage collected (onDestroy) Android Activity Life Cycle Lifetime: onCreate () to onDestroy() Visible when: onStart() ...
Read more >Class Components | Marko
In this case, the component may define a second component class to use the onCreate , onInput , and onRender lifecycle methods.
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
ok, thanks again!
great work, guys
It’s one of those things that’s less confusing if you’re not using JSX