Open ArrayZoneYour opened 5 years ago
Every useStore create a setState now. The cost of communicator middleware will be expensive when the new state passed in setState is huge and the number of components(use useStore hooks) is big.
Enhance:
// before const useStore = (modelName: string, depActions?: string[]) => { const [, setState] = useState(Global.State[modelName].state) // ... } // expected const useStore = (modelName: string, depActions?: string[]) => { // If Context exist const { [modelName]: { setState } } = useContext(GlobalContext) // If not const [, setState] = useState(Global.State[modelName].state) // ... }
Every useStore create a setState now. The cost of communicator middleware will be expensive when the new state passed in setState is huge and the number of components(use useStore hooks) is big.
Enhance: