Closed vadistic closed 5 years ago
I've realised, that I somehow half-assed support for a usecase when somebody would actually want to make use this new init param :grimacing:
The case for inital state worked fine, but now you can properly use initalizer & initializer argument.
Those 3 cases are covered:
// this would work without assertion with added +2 overloads, but it's a bit too tricky for me this morning :)
const [] = useReducer(myReducer, initalState, undefined as any, 'NAME')
const [] = useReducer(myReducer, initialState, state => state, 'NAME')
const init = (arg) => {
hello: arg
}
const [] = useReducer(myReducer, 'world', init, 'NAME')
Also:
@vadistic I can do the signature overloading if you want
@troch I've managed ^^ Just shuffled them.
Also, added like 3 tests, I was halfway done with them so I thought I might commit.
Btw. I irrationally avoid function keyword, so I rarely overload this way (instead of interface overloading) - any idea why the order of overloads mattered here? I've thought it's just simple declaration merging...
I was wondering.. would it make more sense to use a curried pattern for the useReducer
/etc overloads?
eg. useReducer(myId)(normal, params, to, react)
Feels cleaner to me (though obviously a breaking change.. but then it's currently broken anyway.. so..)
Also.. any thoughts on when this might land?
Any updates on this? This is package needs this update ASAP since it's currently unusable in my case due to the 3rd param init and ID conflict.
Hey @antoniojps, yes will finalise it tonight and release.
@troch Thank you for the open source work!
Hello, cool tool! :smile:
I've always been on the 'you may not need redux' side, but with hooks api I may give it a try.
So react 16.8 was released few hours ago and your package (as-is) unfortunately throws invariant violations (code-sandbox example does it too :warning: ).
But I really, really wanted to try it so here's a fix^^
Suggestions:
In case anyone googling for a quick fix:
yarn add vadistic/reinspect#reinspect-v0.4.3-gitpkg