coinbase / onchainkit

React components and TypeScript utilities to help you build top-tier onchain apps.
https://onchainkit.xyz
MIT License
514 stars 114 forks source link

Bug: `createContext` only works in Client Components. Add the `"use client"` directive at the top of the file to use it #325

Closed taycaldwell closed 4 months ago

taycaldwell commented 4 months ago

Describe the bug and the steps to reproduce it

Developers are reporting the following issue:

node_modules/[@coinbase](https://t.me/coinbase)/onchainkit/lib/OnchainKitProvider.js (7:45) @ createContext
 ⨯ createContext only works in Client Components. Add the "use 
client" directive at the top of the file to use it.

When attempting to add a new page with Frame metadata (i.e. yourappname.vercel.app/newPage) outside of the original root page, as described in this tutorial: https://docs.base.org/tutorials/farcaster-frames-transactions#the-first-frame-and-page

What's the expected behavior?

No error is thrown.

What version of the libraries are you using?

Zizzamia commented 4 months ago

@taycaldwell can you share details on what code they used? Also this tutorial https://docs.base.org/tutorials/farcaster-frames-transactions/#the-first-frame-and-page seems outdated.

Like

import { getFrameMetadata } from '@coinbase/onchainkit';

is not the right import anymore, as they should import from @coinbase/onchainkit/frame.

top level is reserved only for the OnchainKitProvider.

@taycaldwell can you work in updating the docs?

Zizzamia commented 4 months ago

In version 0.14.1 we are going to remove getFrameMetadata from the top level import, so there is no more confusion going forward.

@taycaldwell @briandoyle81CB but we still need to update the docs in Base.org