Skip to content

Releases: sbesh91/react-redux-omt

v0.2.0

27 Dec 17:37
Compare
Choose a tag to compare

useWorkerSelector breaking refactor

Between version 0.1.1 and 0.2.0 I've decided to make some slight breaking changes to how the useWorkerSelector hook accepts parameters.

The 0.1.1 syntax looked like this

const one = useWorkerSelector(selectors.one);
const two = useWorkerSelector(selectors.two, ["hello"], "");

The first selector one is really great to keep the same semantics as useSelector. You can see though that there isn't a straight forward way to pass a default value to parameterless selectors.

The 0.2.0 syntax will look like this

const one = useWorkerSelector(selectors.one);
const two = useWorkerSelector(selectors.two, {
  params: ["hello"],
  defaultValue: "",
});

I've decided to move params and defaultValue into one options object that gets the same typing as the former two function arguments.
The options objects are slightly smarter than the arguments were though. For a selector like one you won't see a params option because it's function does not accept parameters beyond the root state.