yyx990803 / vue-hooks

Experimental React hooks implementation in Vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Access context in component constructed using `withHooks`

lmiller1990 opened this issue · comments

If we do something like:

<template>
  <Foo some-prop="someProp" />
</template>

<script>

const Foo = withHooks(h => {
  // state
  const [count, setCount] = useState(0)

  return h("div", [
      h("span", `count is: ${count}`),
    ]
})

export default {
  components: { Foo }
}
</script>

There should be some way to access the props passed too <Foo />. I can't find a way at the moment. I tried to modify the source but couldn't figure it out. Is there some way to pass context as the second arg to withHooks? Eg:

const Foo = withHooks((h, ctx) => {
  // ...
])

I understand this is just a demo, but it's still exciting to explore new possibilities.