@animini/core-react
Advanced tools
Comparing version 0.2.0 to 0.2.1
# @animini/core-react | ||
## 0.2.1 | ||
### Patch Changes | ||
- bf2fd1b: Internal refactoring | ||
- Updated dependencies [bf2fd1b] | ||
- @animini/core@0.2.1 | ||
## 0.2.0 | ||
@@ -4,0 +12,0 @@ |
@@ -10,6 +10,7 @@ 'use strict'; | ||
const animate = core.buildAnimate(target); | ||
return function useAnimini(currentValues, masterConfig) { | ||
return function useAnimini(masterConfig) { | ||
const el = react.useRef(null); | ||
const api = react.useMemo(() => animate(el, currentValues, masterConfig), [currentValues, target]); | ||
const [api] = react.useState(() => animate(el, masterConfig)); | ||
react.useEffect(() => { | ||
api.setCachedValues(); | ||
return () => api.clean(); | ||
@@ -16,0 +17,0 @@ }, [api]); |
@@ -10,6 +10,7 @@ 'use strict'; | ||
const animate = core.buildAnimate(target); | ||
return function useAnimini(currentValues, masterConfig) { | ||
return function useAnimini(masterConfig) { | ||
const el = react.useRef(null); | ||
const api = react.useMemo(() => animate(el, currentValues, masterConfig), [currentValues, target]); | ||
const [api] = react.useState(() => animate(el, masterConfig)); | ||
react.useEffect(() => { | ||
api.setCachedValues(); | ||
return () => api.clean(); | ||
@@ -16,0 +17,0 @@ }, [api]); |
@@ -1,2 +0,2 @@ | ||
import { useRef, useMemo, useEffect } from 'react'; | ||
import { useRef, useState, useEffect } from 'react'; | ||
import { buildAnimate } from '@animini/core'; | ||
@@ -6,6 +6,7 @@ | ||
const animate = buildAnimate(target); | ||
return function useAnimini(currentValues, masterConfig) { | ||
return function useAnimini(masterConfig) { | ||
const el = useRef(null); | ||
const api = useMemo(() => animate(el, currentValues, masterConfig), [currentValues, target]); | ||
const [api] = useState(() => animate(el, masterConfig)); | ||
useEffect(() => { | ||
api.setCachedValues(); | ||
return () => api.clean(); | ||
@@ -12,0 +13,0 @@ }, [api]); |
/// <reference types="react" /> | ||
import { Config, Payload, Target } from '@animini/core'; | ||
export declare function buildReactHook<ElementType, ValueType extends Payload>(target: Target<ElementType, ValueType>): <ElementType_1>(currentValues: any, masterConfig?: Config) => [import("react").RefObject<ElementType_1>, { | ||
export declare function buildReactHook<ElementType, ValueType extends Payload>(target: Target<ElementType, ValueType>): <ElementType_1>(masterConfig?: Config) => [import("react").RefObject<ElementType_1>, { | ||
get: (key: keyof ValueType) => any; | ||
@@ -8,2 +8,3 @@ start: (to: Partial<ValueType>, config?: Config | undefined) => Promise<unknown>; | ||
clean: () => void; | ||
setCachedValues: () => void; | ||
}]; |
{ | ||
"name": "@animini/core-react", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "React core for animini", | ||
@@ -19,4 +19,4 @@ "keywords": [], | ||
"dependencies": { | ||
"@animini/core": "0.2.0" | ||
"@animini/core": "0.2.1" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { useRef, useEffect, useMemo } from 'react' | ||
import { useRef, useEffect, useState } from 'react' | ||
import { buildAnimate, Config, Payload, Target } from '@animini/core' | ||
@@ -7,9 +7,8 @@ | ||
return function useAnimini<ElementType>(currentValues: any, masterConfig?: Config) { | ||
return function useAnimini<ElementType>(masterConfig?: Config) { | ||
const el = useRef<ElementType>(null) | ||
// @ts-ignore | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
const api = useMemo(() => animate(el, currentValues, masterConfig), [currentValues, target]) | ||
const [api] = useState(() => animate(el as any, masterConfig)) | ||
useEffect(() => { | ||
api.setCachedValues() | ||
return () => api.clean() | ||
@@ -16,0 +15,0 @@ }, [api]) |
81
3763
+ Added@animini/core@0.2.1(transitive)
- Removed@animini/core@0.2.0(transitive)
Updated@animini/core@0.2.1