-
-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Labels
nitro-coreIssue is related to the Nitro Modules core runtime/C++ codebaseIssue is related to the Nitro Modules core runtime/C++ codebase
Description
What happened?
When a HybridObject is passed as a prop to a HybridView, calling dispose() on the HybridObject during useEffect cleanup throws:
Exception in HostFunction: failed to define internal native state property
Reproduceable Code
import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-native-nitro-modules'
import type { Base } from './Base.nitro'
export interface TestViewProps extends HybridViewProps {
// ... other props
hybridData?: Base // HybridObject as prop
}
unction ChildWithHybridView({ hybridData }: { hybridData: Base }) {
useEffect(() => {
return () => {
// THIS FAILS with "failed to define internal native state property"
hybridData.dispose()
}
}, [hybridData])
return (
<TestView
hybridData={hybridData} // Pass HybridObject as prop
// ... other props
/>
)
}Relevant log output
DISPOSE - calling hybridData.dispose()...
DISPOSE - ERROR: Error: Exception in HostFunction: failed to define internal native state propertyDevice
iOS Simulator (iPhone 16 Pro, iOS 18.x)
Nitro Modules Version
0.31.10
Nitrogen Version
No response
Can you reproduce this issue in the Nitro Example app here?
Yes, I can reproduce the same issue in the Example app here
Branch:
Steps to reproduce:
- Apply patch to nitro repo (or checkout branch)
- Run
bun specsinpackages/react-native-nitro-test - Run
cd example && bun ios - Navigate to "Dispose" tab
- Tap "Create Object" → "Hide Child"
- Observe error in log
nitro-dispose-hybridview-reproduction.patch
Additional information
- I am using Expo
- I am using nitrogen
- I have read and followed the Troubleshooting Guide.
- I created a reproduction PR to reproduce this issue here in the nitro repo. (See Contributing for more information)
- I searched for similar issues in this repository and found none.
Metadata
Metadata
Assignees
Labels
nitro-coreIssue is related to the Nitro Modules core runtime/C++ codebaseIssue is related to the Nitro Modules core runtime/C++ codebase