Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
nandorojo committed Jan 29, 2025
1 parent 5790b4f commit 2812f35
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/moti/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "moti",
"description": "The universal React Native animation library, powered by Reanimated 3. 🦉",
"version": "0.29.0",
"version": "0.30.0",
"keywords": [
"react-native",
"ios",
Expand Down
2 changes: 1 addition & 1 deletion packages/moti/src/core/use-animator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default function useAnimationState<V extends Variants<V>>(
to = 'to' as keyof V,
}: UseAnimationStateConfig<V> = {}
) {
const controller = useRef<UseAnimationState<V>>()
const controller = useRef<UseAnimationState<V>>(null)
const __state = useSharedValue<InternalControllerState<V>>(
from ? _variants[from] : 0
)
Expand Down
2 changes: 1 addition & 1 deletion packages/moti/src/core/use-dynamic-animation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function useDynamicAnimation<

const __state = useSharedValue(initializer.current.value)

const controller = useRef<UseDynamicAnimationState<Animate>>()
const controller = useRef<UseDynamicAnimationState<Animate>>(null)

if (controller.current == null) {
controller.current = {
Expand Down
13 changes: 9 additions & 4 deletions packages/moti/src/interactions/pressable/hoverable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,20 @@ function isHoverEnabled(): boolean {
return isEnabled
}

import React, { useCallback, ReactChild, useRef, useEffect } from 'react'
import React, {
useCallback,
ReactElement as ReactChild,
useRef,
useEffect,
} from 'react'
import { useSharedValue, useAnimatedReaction } from 'react-native-reanimated'
import { HoveredContext } from './hoverable-context'
import { mergeRefs } from './merge-refs'

export interface HoverableProps {
onHoverIn?: () => void
onHoverOut?: () => void
children: NonNullable<ReactChild>
children: ReactChild
childRef?: React.Ref<any>
}

Expand Down Expand Up @@ -123,15 +128,15 @@ export function Hoverable({
}
}, [isHovered])

const child = React.Children.only(children) as React.ReactElement
const child = React.Children.only(children)

return (
<HoveredContext.Provider value={isHovered}>
{React.cloneElement(child, {
onMouseEnter: handleMouseEnter,
onMouseLeave: handleMouseLeave,
ref: mergeRefs([localRef, childRef || null]),
})}
} as any)}
</HoveredContext.Provider>
)
}

0 comments on commit 2812f35

Please sign in to comment.