#Update state doesn't work in hook

2 messages · Page 1 of 1 (latest)

bright swan
#

Hello everyone,

I'm trying to implement a hook called useCarousel to have a carousel in an easy way without adding too much logic/animations to my components.
The problem is that I've encountered many "bugs" with the state, because it doesn't update !

I use several useEffect and useCallback in my code, but I'm sure that I've implemented them properly so they should be working !

You can have a simple example with the handleDrag function, triggered from the onDrag parameter in my Draggable options.
Originally, my direction state is 0, I update the state with setDirection to "ok" just to see any difference, but nothing, still getting 0 in the console.log.

Anyone have an idea of what's causing this ?

remote boughBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)