Skip to content

Globally shared state by ReducerModuleFunc, and re-renderer the components if the corresponding ClassState is updated. #106

@chhsiao1981

Description

@chhsiao1981

Currently each new ClassState is created when using useReducer.

Furthermore, all the ClassStates are created in the parent-components.
If we want to get the ClassState in the child-components, then
we need to pass it with props.

It is better to have a shared state by ReducerModuleFunc,
and re-render the components if the corresponding ClassState is updated.

Therefore, given ReducerModuleFuncA, ClassStateA, ParentComponent, ChildComponent, and GrandChildComponent:

  1. If we useReducer(ReducerModuleFunc) in ParentComponent, ChildComponent, and GrandChildComponent,
    for the same id, they should be able to access the same state.
  2. If some dispatch is triggered in GrandChildComponent, then ParentComponent, ChildComponent, and GrandChildComponent should all be re-rendered.
  3. For simplicity, ideally only the id is passed through the components. However, this may violate the reactjs principle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions