'Redux with React design of dispatch

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 the entire process away by providing an interface that can access the state.

For example what would be wrong with the below definition:

export function setDefaultUnits(measure_: keyof defaultUnits_state_type_, quantity_: Quantity, store_: Store = store)

and subsequent call from within a component:

setDefaultUnits('distance', Quantity('meters')) that implicitly accesses the current store, serializes the Quantity object and stores it in the state but effectively abstracts away state implementation details?

I think automating serialization and de-serialization are 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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source