matthewp / haunted

React's Hooks API implemented for web components 👻

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I create a hook like this?

izengliang opened this issue · comments

I want this , don't link extends Hook class. Can i?

export function useAddHook(num){
   const [state, setState]  =   useState(0)

   useEffect(()=>{
       setState(state + num);
  },[num]);

   return state;
}

Sure you can ... combining hooks is the best way to create new hooks.

Anthony.

Yep, the Hook class is only for low levels hooks.