question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What if a certain element gets changed when the component that generates it changes, but the oncreate callback does not get called?

See original GitHub issue

Say:

var Component = function () {
    return <div oncreate={
            function () { /* do something that never gets called? */ }
        }>Some text</div>;
};
app({
    root: document.body,
    view: function (state, actions) {
        return state.condition ? <div class="clickable" onclick={actions.change} /> : <Component />;
    },
    state: {
        condition: true
    },
    actions: {
        change: function () {
            return {
                condition: false
            };
        }
    }
});

Would the oncreate callback ever get called?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
jorgebucarancommented, Sep 30, 2017

@infinnie What if the root were a list, a table, or a flex?

I am not sure if this is exact answer you were looking for, but whatever your application’s root element may be, you can always do this:

<main>
  <!-- Put whatever you want here. -->
</main>

And you can always return arrays from components.

1reaction
jorgebucarancommented, Sep 29, 2017

@infinnie Do you want to give it a shot?

Read more comments on GitHub >

github_iconTop Results From Across the Web

The activity lifecycle | Android Developers
The Activity class provides a number of callbacks that allow the activity to know that a state has changed: that the system is...
Read more >
Activity lifecycle - onCreate called on every re-orientation
Yes, activity's onCreate() is called everytime when the orientation changes but you can avoid the re-creation of Activity by adding configChanges attribute ......
Read more >
Callbacks — NUKE Python Developer's Guide v10.5v1 ...
Hidden knobs include onCreate, onDestroy, knobChanged, updateUI, and autolabel. If there are many callbacks registered, code attached to knobs is always called ......
Read more >
Lifecycle methods - Mithril.js
Lifecycle methods are only called as a side effect of a m.render() call. They are not called if the DOM is modified outside...
Read more >
Realtime Database triggers | Cloud Functions for Firebase
You can make Firebase Realtime Database changes via the DataSnapshot or via the ... If you do not specify an instance, the function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found