Closed adsko closed 3 years ago
Fixed in new release, see Docs - Custom Component.
All you need to do is set preventAutoDestroy: true
and you're good to go
@inlet I think, children destroy also should be affected by this flag.
We don't know if everything is added to children (some container, sprites etc may be in memory).
This is also handled by the reconciler, see
@inlet But you assume that every pixi component to destroy is in children array. Some of them may be in memory, see: https://github.com/pixijs/spine/blob/b50a4bfc01be727f86b74ddb2963b0363f5d8a3f/packages/base/src/SpineBase.ts#L745
Some containers and sprites are stored in class fields. Because of it, there may be memory leak if we enable "preventAutoDestroy".
It would be nice to have second flag like: "preventChildrenDestroy": boolean; And with these two flags, we can manage almost all cases.
what about we provide a config
object like this?
{
config: {
destroy: false,
destroyChildren: false
},
create: () => {},
applyProps: () => {},
willUnmount: () => {}
}
@inlet It makes sense to group it in object.
Adding a patch now...
Hopefully this fix helps you
Description
Currently, a code to remove a component from a tree looks like this:
It makes an issue with pixi components, which manages children on its own. See issue: https://github.com/pixijs/spine/issues/389
Pixi spine makes children on its own and destroy them in destroy method. Because of it, there is no way to manage component like this in react-pixi, because react-pixi will call destroy for each child and call destroy on the spine component.
I think, there should be a way to manage situation like this.
Steps to reproduce
Make component like this:
Additional info