I am fairly new to Redux and even though I understand reducers and dispatching, I am puzzled by the way Redux is used in React components.
Why use hooks like useSelector and useDispatch with fairly complicated (but still customized) action creators while we can abstract all of the process away by providing an interface that can access the state:
For example what would be wrong with the below call within a component:
export function setDefaultUnits(measure_: keyof defaultUnits_state_type_, quantity_: Quantity, store_: Store = store)
setDefaultUnits('distance', Quantity('meters'))
that implicitly accesses the current store, serializes the Quantity object and stores it in the state?
I think automating serialization and de-serialization is important enough to use entirely custom functions for the state that are then used in React components.
Is there a design philosophy that compels us to use useDispatch and useSelector?
Aucun commentaire:
Enregistrer un commentaire