immerjs / use-immer

Use immer to drive state with a React hooks
MIT License
4.04k stars 92 forks source link

Automatically convert types? #26

Closed corysimmons closed 5 years ago

corysimmons commented 5 years ago

I'd love it if I could get rid of the if (e.target.type === 'number') check: https://codesandbox.io/s/useimmer-demo-5ulb7

Sidenote: It would also be super amazing/ideal if I could get rid of the e.persist() 😍

mweststrate commented 5 years ago

You wish React to work differently. But that all seems completely out of scope for useImmer :)

On Fri, Jun 7, 2019 at 10:17 AM Cory Simmons notifications@github.com wrote:

I'd love it if I could get rid of the if (e.target.type === 'number') check: https://codesandbox.io/s/useimmer-demo-5ulb7

Sidenote: It would also be super amazing/ideal if I could get rid of the e.persist() 😍

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/immerjs/use-immer/issues/26?email_source=notifications&email_token=AAN4NBGS7HM7TQDSOV4ZWFDPZIKRJA5CNFSM4HVTMWTKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GYGHE6Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AAN4NBC74OVGXNOXSZPW4SLPZIKRJANCNFSM4HVTMWTA .

corysimmons commented 5 years ago

I think maintaining types could/should be in scope for Immer. I think you're right about e.persist() not being in scope of Immer, though.

mweststrate commented 5 years ago

Sorry, I really don't get what the type of e.target.type has to do with immer, e is coming from react, not immer.

corysimmons commented 5 years ago

Yeah you're 100% right now that I look at it closer.

https://codepen.io/corysimmons/pen/BeXdEK?editors=0010

Seems like browsers pass e.target.value as a string no matter what.

💀 Sorry for wasting your time.