score:0

i don't see any issue in the shared code but i can point 1 area which might be causing problem for you.

i guess it's the moment() which returns a date object. i am not sure whats the appointment format you have in props, so if you can share these details then probably i can share the whole code or just give it a try, it shouldn't be that complex.

i have created a demo without moment, which works fine.

https://codesandbox.io/s/serene-davinci-quxz1?fontsize=14&hidenavigation=1&theme=dark

also instead of directly putting the function in usestate, try this

  const initialnextappointment = getnextappointment(appointments);
  var [nextappointment, setnextappointment] = react.usestate(
    initialnextappointment
  );

let me know if this helps!


Related Query

More Query from same tag