@@ -34,22 +34,29 @@ function FusionLib(props: MounterProps<"FusionLib">) {
34
34
const fusionProps : InferFusionProps < ConvertedControls > = GetProps ( {
35
35
controls : fusionValues ,
36
36
target : props . MountFrame ,
37
+ scope : Cast < Fusion3 > ( fusion ) ,
37
38
} ) ;
38
39
39
40
const [ success , value ] = pcall ( ( ) => result . story ( fusionProps ) ) ;
40
41
if ( ! success ) {
41
- warn ( "UI- Labs: Fusion story errored when mounting. The cleanup function will not be executed: " , value ) ;
42
+ warn ( "UI Labs: Fusion story errored when mounting. The cleanup function will not be executed: " , value ) ;
42
43
return ( ) => {
43
- warn ( "UI- Labs: The cleanup function was not found. This might be due to the story erroring. This may cause a memory leak." ) ;
44
+ warn ( "UI Labs: The cleanup function was not found. This might be due to the story erroring. This may cause a memory leak." ) ;
44
45
} ;
45
46
}
46
- return typeIs ( value , "Instance" ) ? ( ) => value . Destroy ( ) : value ;
47
+ return value ? ( typeIs ( value , "Instance" ) ? ( ) => value . Destroy ( ) : value ) : undefined ;
47
48
} , [ ] ) ;
48
49
49
50
useStoryUnmount ( result , ( ) => {
50
- const [ success , err ] = pcall ( cleanup ) ;
51
- if ( ! success ) {
52
- warn ( "UI-Labs: The cleanup function errored when unmounting. This may cause a memory leak: " , err ) ;
51
+ if ( cleanup ) {
52
+ const [ success , err ] = pcall ( cleanup ) ;
53
+ if ( ! success ) {
54
+ warn ( "UI Labs: The cleanup function errored when unmounting. This may cause a memory leak: " , err ) ;
55
+ }
56
+ } else {
57
+ if ( version === "Fusion2" ) {
58
+ warn ( "UI Labs: No cleanup function was returned for Fusion 2.0, there's no way to cleanup the story." ) ;
59
+ }
53
60
}
54
61
if ( version === "Fusion3" ) {
55
62
Cast < Fusion3 > ( fusion ) . doCleanup ( fusion ) ;
0 commit comments