Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this is not pointing at instance of called class #10

Open
ghost opened this issue Dec 17, 2021 · 0 comments
Open

this is not pointing at instance of called class #10

ghost opened this issue Dec 17, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 17, 2021

this is not bound in created and destroyed, so it's hard to access custom context variables:

export class TestComponent extends Rete.Component {
  constructor(foo) {
    super("Test");
    this.foo = foo;
  }
  created(node) {
    console.log(`Created ${node.id} for ${this.foo}`); // Won't work, because `this` will be `undefined`
  }
}

The function hooks should be bound to the respective class instance.


Background

In my particular use-case, I'd like to have a context variable (equivalent to foo) point at a container DOM element and each node owns a DOM child that is attached to the container DOM element. However, during node creation / destruction I'm unable to find the container DOM element, because this is undefined.

@ghost ghost mentioned this issue Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

0 participants