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.

before lifecycle methods?

See original GitHub issue

Any chance for a beforeOnDetached lifecycle event?

I am using my Position component’s onAttached method to add the id to an entities at location cache. I tried to use the onDetached method for removing it from that cache but by the time the method fires the Position component is already gone so I can’t find the entity in my cache to remove it.

Would be great to expand on the lifecycle methods to allow for this.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
O4epegbcommented, Jul 29, 2020

@luetkemj I am following your tutorial and it is actually possible to do right now.

  onDetached() {
    const locId = `${this.x},${this.y}`;
    entitiesCache.delete(locId, this.entity.id);
  }

So this is actually component itself and it still has entity field with his entity it was attached. Although entity does not have Position already, but it does not needed.

1reaction
ddmillscommented, Nov 27, 2020

@luetkemj I don’t believe the query will have access to the component that was removed/added, but it has access to the entity that was changed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lifecycle hooks - Angular
In this example, the doSomething() method updates the screen when the hero name exceeds 10 characters, but waits a tick before updating comment...
Read more >
React lifecycle methods: An approachable tutorial with examples
Learn all about React lifecycle methods for mounting, updating, unmounting, and error handling, including new methods as of React 17.
Read more >
React.Component
Each component has several “lifecycle methods” that you can override to run code ... The constructor for a React component is called before...
Read more >
React Lifecycle - W3Schools
The three phases are: Mounting, Updating, and Unmounting. Mounting. Mounting means putting elements into the DOM. React has four built-in methods that gets ......
Read more >
The React lifecycle: methods and hooks explained - Retool
The constructor method is called when the component is initiated, but before it's rendered. It's also called with props as an argument. It's ......
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