devhammed / use-global-hook

Painless global state management for React using Hooks and Context API in 1KB!

Home Page:https://hammed.dev/use-global-hook/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array.prototype.map() expects a return value from arrow function

pmartiamarista opened this issue · comments

hooks.map((hook) => {
if (typeof hook !== "function") {
throw new TypeError(
Provided global hook value "${hook}" is not a function.
);
}

hooks.map((hook) => {
stores[hook] = useGlobalHook(hook);
});
Hi, .map needs a return value. you can use forEach() to iterate de Array. Very useful Hook by the way. I change the example with useReducer
const [state, dispatch] = useReducer(countReducer, {
...initialState,
});
Works great!

@pmartiamarista Oh yeah, I will do that ASAP and thank you for checking out the library.