Skip to content

Commit

Permalink
fix: children for MotiPressable & Skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
nandorojo committed Mar 28, 2022
1 parent 1bbedf0 commit 1a99002
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
15 changes: 14 additions & 1 deletion packages/moti/src/interactions/pressable/pressable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,23 @@ export const MotiPressable = forwardRef<View, MotiPressableProps>(
transition={transition}
exitTransition={exitTransition}
state={state}
// TODO change API to this
// animate={useMemo(() => {
// 'worklet'

// if (typeof animate === 'function') {
// return animate(interaction.value)
// }

// return animate
// }, [])}
style={style}
onLayout={onLayout}
>
{typeof children == 'function' ? children(interaction) : children}
{typeof children == 'function'
? // @ts-expect-error it thinks ReactNode can be a function, but it's fine.
children(interaction)
: children}
</MotiView>
)

Expand Down
2 changes: 1 addition & 1 deletion packages/moti/src/interactions/pressable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export type MotiPressableProps = {
onContainerLayout?: PressableProps['onLayout']
href?: string
children?:
| React.ReactElement
| React.ReactNode
| ((
interaction: DerivedValue<MotiPressableInteractionState>
) => React.ReactNode)
Expand Down
5 changes: 2 additions & 3 deletions packages/moti/src/skeleton/skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Props = {
* Optional height of the skeleton. Defauls to a `minHeight` of `32`
*/
height?: number | string
children?: React.ReactChild
children?: React.ReactChild | null
/**
* `boolean` specifying whether the skeleton should be visible. By default, it shows if there are no children. This way, you can conditionally display children, and automatically hide the skeleton when they exist.
*
Expand Down Expand Up @@ -204,10 +204,9 @@ const AnimatedGradient = React.memo(
}: {
measuredWidth: number
colors: string[]
backgroundSize: number,
backgroundSize: number
transition?: MotiTransitionProp
}) {

return (
<MotiView
style={StyleSheet.absoluteFillObject}
Expand Down

0 comments on commit 1a99002

Please sign in to comment.