SolidJSS
SolidJSโ€ข3y agoโ€ข
7 replies
uchiha_savior

Derived value in event handler causing router error

Error: Make sure your app is wrapped in a <Router /> when calling an eventhandler. Just trying to log a derived signal/prop in my buy function. The values from product() get printed correctly in my DOM

  const product = () => props.product
  const [qty, setQty] = createSignal(0)

  function buy() {
    console.log(product())
    // console.log(qty())
  }


The second console.log works fine. But the first throws
Uncaught Error: Make sure your app is wrapped in a <Router />
    at invariant (utils.js?v=8381e9f0:28:15)
    at useRouter (routing.js?v=8381e9f0:9:32)
    at useRoute (routing.js?v=8381e9f0:11:75)
    at useParams (routing.js?v=8381e9f0:37:32)
    at product (ProductDetail.tsx:11:22)
Was this page helpful?