Skip to content

Commit 08ea8fa

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 08ea8fa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/animated/src/withAnimated.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ 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) ||
41+
(Component.prototype && Component.prototype.isReactComponent)
4142

4243
const forceUpdate = useForceUpdate()
4344
const props = new AnimatedProps(() => {

0 commit comments

Comments
 (0)