fix dispose

This commit is contained in:
Paul Henschel
2020-09-06 20:15:35 +02:00
parent f2973382a9
commit ea5c9cef83
2 changed files with 5 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "react-three-fiber",
"private": true,
"version": "5.0.0-alpha.1",
"version": "5.0.0-alpha.2",
"description": "A React renderer for Three.js (web and react-native)",
"keywords": [
"react",

View File

@@ -1,6 +1,7 @@
import * as THREE from 'three'
import React from 'react'
import Reconciler from 'react-reconciler'
// @ts-ignore
import Reconciler from 'react-reconciler/cjs/react-reconciler.production.min'
import { unstable_now as now, unstable_IdlePriority as idlePriority, unstable_runWithPriority as run } from 'scheduler'
import { CanvasContext } from './canvas'
@@ -311,6 +312,7 @@ function createInstance(
props = { dispose: null, ...props }
instance = props.object
instance.__instance = true
instance.__dispose = instance.dispose
} else if (type === 'new') {
instance = new props.object(args)
} else {
@@ -435,6 +437,7 @@ function removeChild(parentInstance: any, child: any) {
removeRecursive(child.children, child, true)
// Dispose item
if (child.dispose) child.dispose()
else if (child.__dispose) child.__dispose()
// Remove references
delete child.__container
delete child.__objects