Skip to content

Commit

Permalink
fix: useMotiPressable* on Web without plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nandorojo committed Feb 17, 2023
1 parent cdb4a5d commit aa76030
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 9 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.23.6](https://github.com/nandorojo/moti/compare/v0.23.4...v0.23.6) (2023-02-15)


### Bug Fixes

* hoverable without swc plugin ([cdb4a5d](https://github.com/nandorojo/moti/commit/cdb4a5dddafe96b76281108f7f6222291e4f8fb7))





## [0.23.5](https://github.com/nandorojo/moti/compare/v0.23.4...v0.23.5) (2023-02-14)

**Note:** Version bump only for package moti
Expand Down
11 changes: 11 additions & 0 deletions examples/with-expo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.23.6](https://github.com/nandorojo/moti/compare/v0.23.4...v0.23.6) (2023-02-15)


### Bug Fixes

* hoverable without swc plugin ([cdb4a5d](https://github.com/nandorojo/moti/commit/cdb4a5dddafe96b76281108f7f6222291e4f8fb7))





## [0.23.5](https://github.com/nandorojo/moti/compare/v0.23.4...v0.23.5) (2023-02-14)

**Note:** Version bump only for package with-expo
Expand Down
2 changes: 1 addition & 1 deletion examples/with-expo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "with-expo",
"description": "Example app for moti",
"version": "0.23.5",
"version": "0.23.6",
"private": true,
"scripts": {
"android": "expo run:android",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"npmClient": "npm",
"useWorkspaces": true,
"version": "0.23.5",
"version": "0.23.6",
"command": {
"publish": {
"allowBranch": "master",
Expand Down
11 changes: 11 additions & 0 deletions packages/moti/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.23.6](https://github.com/nandorojo/moti/compare/v0.23.4...v0.23.6) (2023-02-15)


### Bug Fixes

* hoverable without swc plugin ([cdb4a5d](https://github.com/nandorojo/moti/commit/cdb4a5dddafe96b76281108f7f6222291e4f8fb7))





## [0.23.5](https://github.com/nandorojo/moti/compare/v0.23.4...v0.23.5) (2023-02-14)

**Note:** Version bump only for package moti
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function useInterpolateMotiPressable<Props>(
): Readonly<Animated.SharedValue<Props>> {
const context = useMotiPressableContext()

const { factory, id, deps } = useFactory<Factory<Props>>(
const { factory, id, deps = [] } = useFactory<Factory<Props>>(
'useMotiPressableAnimatedProps',
factoryOrId,
maybeFactoryOrDeps,
Expand All @@ -96,5 +96,5 @@ export function useInterpolateMotiPressable<Props>(

return useDerivedValue<Props>(() => {
return context && factory(context.containers[id].value)
}, deps)
}, [...deps, context.containers[id]])
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function useMotiPressableTransition(
): Readonly<Animated.SharedValue<MotiTransition>> {
const context = useMotiPressableContext()

const { factory, id, deps } = useFactory<Factory<MotiTransition>>(
const { factory, id, deps = [] } = useFactory<Factory<MotiTransition>>(
'useMotiPressableAnimatedProps',
factoryOrId,
maybeFactoryOrDeps,
Expand All @@ -90,5 +90,5 @@ export function useMotiPressableTransition(

return useDerivedValue<MotiTransition>(() => {
return context && factory(context.containers[id].value)
}, deps)
}, [context.containers[id], ...deps])
}
4 changes: 2 additions & 2 deletions packages/moti/src/interactions/pressable/use-pressable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function useMotiPressable(
): MotiProps['state'] {
const context = useMotiPressableContext()

const { factory, id, deps } = useFactory<MotiPressableInteractionProp>(
const { factory, id, deps = [] } = useFactory<MotiPressableInteractionProp>(
'useMotiPressable',
factoryOrId,
maybeFactoryOrDeps,
Expand All @@ -103,7 +103,7 @@ function useMotiPressable(
const interaction = context.containers[id]

return interaction && factory(interaction.value)
}, deps)
}, [context, id, context.containers[id], ...deps])

return useMemo(
() => ({
Expand Down
3 changes: 2 additions & 1 deletion packages/moti/src/interactions/pressable/use-pressables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { MotiPressableContext, useMotiPressableContext } from './context'
import type { MotiPressableInteractionProp } from './types'
import { useDerivedValue } from 'react-native-reanimated'
import { useMemo } from 'react'
import { Platform } from 'react-native'

type Factory = (
containers: MotiPressableContext['containers']
Expand Down Expand Up @@ -78,7 +79,7 @@ export function useMotiPressables(

return animatedResult
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [context.containers, ...deps])
}, [context.containers, Platform.select({ web: factory }), ...deps])

const state = useMemo(() => ({ __state }), [__state])

Expand Down

0 comments on commit aa76030

Please sign in to comment.