I have been reading the documentation reanimated 2 Hooks and searched all the internet for the better explained blog or any code but couldn't find any one , Can anyone please explain and give example with source code .As example
const App = () => {
const [state, setState] = useState(0);
const sv = useSharedValue(0);
const handler = useAnimatedGestureHandler(
{
onEnd: (_) => {
sv.value = state;
},
},
dependencies
);
//...
return <></>;
};
But when i tried as
const [test, setTest ] = useState(true);
const gestureHandler = useAnimatedGestureHandler({
onStart : (event,context)=>{
console.log("onstart");
setTest(true);
context.startX = X.value;
},
onActive : (event,context)=>{
console.log("onactive");
X.value = context.startX + event.translationX;
},
onEnd : (event,context)=>{
console.log("onEnd");
setTest(false);
}
},
[test]
)
i got error as
Tried to Synchronously call function (bound dispatchAction)
from different thread.