Skip to content
Discussion options

You must be logged in to vote

useContext must be called inside an owner , to simply put, once the component initializes. Not inside an event handler where there's no owner usually but can be made to.

const One = () => {
  const ctx = useContext(key)
  return <button onClick={() => {
    // access the resolved ctx value here
  }}>click</button>
}

Why it seems to worked in the original example is because startTransition has a bug here where it left the owner and listener without cleaning them up after it's finished https://github.com/solidjs/solid/blob/main/packages/solid/src/reactive/signal.ts#L940-L941

Bug with left up listener https://playground.solidjs.com/?hash=167881774&version=1.3.13

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@iamcco
Comment options

Answer selected by iamcco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants