yyx990803 / vue-hooks

Experimental React hooks implementation in Vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature]Maybe we can provide createElement in hooks, to cache the created vdom? Or just passing instance into hooks?

TotooriaHyperion opened this issue · comments

Because the hooks are run in beforeMount where the instance object is already created.
We know that createElement is bound to the instance, so may I assume that meanwhile we can createElement and cache the result?

The API might looks like

hooks(props, instance) {
    const h = instance.$createElement;
    const cachedVNode  = useMemo(....); // some custom hook
    return {
        cachedVNode,
    };
},