dy / unihooks

Universal unreacted hooks
MIT License
21 stars 1 forks source link

useAction #33

Closed dy closed 4 years ago

dy commented 4 years ago

Some points to reform useAction hook.

  1. useAction is very similar to useCallback - in the same way as useStore is named extension of useState, the useAction is named extension of useCallback.
  2. actions are not necessary to be hooks enabled. All that is required for an action can be defined in (main) component, initializing that action.
  3. 2. allows getting rid of createAction (which now makes actions complex - passive mode etc).
dy commented 4 years ago

Without createAction there comes a simple problem of circular dependencies. One component may want to use value that is going to be defined by another component. Since live bindings are not available for hooks, that can be solved only by main components for now.

So, some components can be shallow-rendered with empty values, and then re-rendered with values re-defined by another components.

That may even cause that some components, using actions defined by another async/lazy/non-present components are rendered without these actions available.

dy commented 4 years ago

Actions are removed.