form-atoms / list-atom

A listAtom extension for the Jotai form-atoms.
https://form-atoms.github.io/list-atom/
MIT License
4 stars 1 forks source link

Typescript : initialValues should have RESET allowed #8

Closed pgangwani closed 2 months ago

pgangwani commented 6 months ago

Describe the bug I noticed that List component has missing type to accept RESET symbol.

To Reproduce Steps to reproduce the behavior:

  1. Create <List ..>
  2. Add prop initialValue={RESET} in case of
  3. See the ts error

Expected behavior Like initialValue in useList(,{initialValue}), it should accept RESET symbol.

Screenshots If applicable, add screenshots to help explain your problem.

Screenshot 2024-05-13 at 11 05 27 PM Screenshot 2024-05-13 at 11 02 09 PM

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

pgangwani commented 6 months ago

@MiroslavPetrik : Please review this issue and PR . Let me know if any question.

MiroslavPetrik commented 5 months ago

The useFieldInitialValue hook indeed accepts the RESET symbol, so the request seems valid. But looking at it practically, I would advise not to use it in such a way. The purpose of the initialValue prop is to set the hydrated data, e.g. when you fetch that from the server. The RESET symbol value, is to clear any changes back to the first hydrated value, which best is done via the reset action.

Do you really need it?

MiroslavPetrik commented 2 months ago

https://github.com/form-atoms/list-atom/pull/9#issuecomment-2348561417