Skip to content

Commit c4d4cf0

Browse files
committed
fix: make animated work with arrow function component
When we pass arrow function component, it will throw error because in `createAnimatedComponent` we check `Component.prototype.isReactComponent` to check if it's component created by `create-react-class`, but arrow function doesn't have `.prototype` property. This commit additionally check if `.prototype` exists.
1 parent 162b2be commit c4d4cf0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/animated/src/withAnimated.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const createAnimatedComponent = (Component: any) =>
3737
const hasInstance: boolean =
3838
// Function components must use "forwardRef" to avoid being
3939
// re-rendered on every animation frame.
40-
!is.fun(Component) || Component.prototype.isReactComponent
40+
!is.fun(Component) || Object.getPrototypeOf(Component).isReactComponent
4141

4242
const forceUpdate = useForceUpdate()
4343
const props = new AnimatedProps(() => {

0 commit comments

Comments
 (0)