estrelajs / estrela

Full Reactive Framework.
https://estrelajs.github.io/
MIT License
51 stars 0 forks source link

Life cycle hook doesn't work when you have a template called before it. #11

Open rosostolato opened 1 year ago

rosostolato commented 1 year ago

If you create a template before calling the component life cycle hook (onInit, onDestroy), it won't work:

function App() {
  const template = <MyComponent />;

  onDestroy(() => {});

  return (
    <div>{template}</div>
  );
}

image

rosostolato commented 1 year ago

I realized that it doesn't work when the template is mounted before you call the hook. Need to update the currentComponent to be an instance stack with all the component tree within it.