the cursor cannot work in a complex layout because of the re-renders, each time you move the mouse all components re-render and the mouse starts lagging in a complex application.
Thank you so much :)
I did. It does sometimes lag on the initial paint. I'll try to update the blog if I find a solution for that. Do you have something in mind?
Yeah i was tinkering with the same effect but using refs instead:
constcursorRef=React.useRef<HTMLDivElement>(null!);constmoveListener=React.useCallback((event)=>{const{clientX,clientY,target}=event;if(target==='target-id'){// some custom logic to change cursor icon in here}constmouseX=clientX-cursorRef.current.clientWidth/2;constmouseY=clientY-cursorRef.current.clientHeight/2;})return<divclassName='custom-cursor'ref={cursorRef}/></div>;
I dont get the lag with this method, but i'm hitting a bug with css animations when doing this method 😕
the cursor cannot work in a complex layout because of the re-renders, each time you move the mouse all components re-render and the mouse starts lagging in a complex application.
same problem brother, have you solved this problem??
Do you have any solution that may fix this problem ?
Don't use context like this example does. I would solve this with some atomic state library outside react like jotai or recoil, valtio works too.
Nice, I like this a lot! Did you notice some janky behaviour when using the delayed animation? re:
transition-duration: 100ms;Thank you so much :)
I did. It does sometimes lag on the initial paint. I'll try to update the blog if I find a solution for that. Do you have something in mind?
Yeah i was tinkering with the same effect but using refs instead:
I dont get the lag with this method, but i'm hitting a bug with css animations when doing this method 😕
is it in the hooks file
?
Thanks for the detailed walk through.
Awesome article; but the hover effect does not work. what can I do to make I work?
Thank you!
I just checked the code again. It should work, you can try to compare your code with this codesandbox.io/s/competent-hodgkin...
Hope you get it sorted :)