code look fine issue might be somewhere else
here is sandbox I tried https://codesandbox.io/p/devbox/peaceful-wing-7k654w?workspaceId=ws_Q5TTAYWhq3YSybYKpigpM8