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

Memory leak in the tutorial example #47

Open
jjagielka opened this issue Aug 17, 2022 · 0 comments
Open

Memory leak in the tutorial example #47

jjagielka opened this issue Aug 17, 2022 · 0 comments

Comments

@jjagielka
Copy link

Tutorial shows the example implementation and we can find there:

 show() {
   ...
  modifiers: [
                ...options.modifiers,
                { name: 'eventListeners', enabled: true }, 
            ]

options.modifiers is an array, so the above code keeps on adding new object at each call of show().

The same mistake is in hide() function.

You should change it to something like that:

function enableListeners(modifiers, value) {
   const modifier = modifiers.find((x) => x.name === 'eventListeners');
   if (!modifier) return [...modifiers, { name: 'eventListeners', enabled: open }];
   modifier.enabled = value;
   return modifiers;
}

show() {
   ...
   modifiers: enableListeners(options.modifiers, true)
   ...
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

No branches or pull requests

1 participant