Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'useUIState' is not exported from 'ai/rsc' #1511

Closed
RaduIm opened this issue May 7, 2024 · 5 comments
Closed

'useUIState' is not exported from 'ai/rsc' #1511

RaduIm opened this issue May 7, 2024 · 5 comments
Labels

Comments

@RaduIm
Copy link

RaduIm commented May 7, 2024

Description

When I try to run build, I get:

   ⚠ Compiled with warnings

....../components/chat/chat-messages.tsx
Attempted import error: 'useUIState' is not exported from 'ai/rsc' (imported as 'useUIState').

Because of the warning, my deployment to Vercel fails.

Code example

import { useUIState } from "ai/rsc";

const ChatMessages = () => {
  const [messages] = useUIState<typeof AI>();

Additional context

"dependencies": {
    "@ai-sdk/openai": "^0.0.9",
    "@emotion/cache": "^11.11.0",
    "@emotion/react": "^11.11.4",
    "@emotion/server": "^11.11.0",
    "@emotion/styled": "^11.11.5",
    "@mui/icons-material": "^5.15.15",
    "@mui/material": "^5.15.15",
    "@vercel/blob": "^0.23.2",
    "ai": "^3.1.1",
    "aos": "^2.3.4",
    "date-fns": "^3.6.0",
    "date-fns-tz": "^3.1.3",
    "next": "^14.2.3",
    "openai": "^4.40.1",
    "react": "^18",
    "react-dom": "^18",
    "react-markdown": "^9.0.1",
    "react-material-ui-carousel": "^3.4.2",
    "react-slick": "^0.30.2",
    "remark-gfm": "^4.0.0",
    "slick-carousel": "^1.8.1",
    "use-debounce": "^10.0.0",
    "zod": "^3.22.4",
    "zod-to-json-schema": "^3.22.5"
  },
  "devDependencies": {
    "@types/aos": "^3.0.7",
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "@typescript-eslint/eslint-plugin": "^7.6.0",
    "@typescript-eslint/parser": "^7.6.0",
    "constructs": "^10.3.0",
    "eslint": "^8",
    "eslint-config-next": "^14.2.3",
    "eslint-plugin-react": "^7.34.1",
    "prettier": "^3.2.5",
    "typescript": "^5"
  }
@lgrammel
Copy link
Collaborator

lgrammel commented May 8, 2024

Are you using es modules or commonjs? Would you mind sharing your tsconfig.json?

@RaduIm
Copy link
Author

RaduIm commented May 8, 2024

Here is my tsconfig.json. Thanks for looking into this!

{
  "compilerOptions": {
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

@lonelyheartsclubcode
Copy link

were you able to resolve this? i'm struggling with a similar issue

@shuding
Copy link
Member

shuding commented May 14, 2024

useUIState is a Client Component API, which means that you have to use it in a Client Component (with "use client" directive on top):

"use client"

import { useUIState } from "ai/rsc"

Let me know if this solves your issue!

@RaduIm
Copy link
Author

RaduIm commented May 16, 2024

useUIState is a Client Component API, which means that you have to use it in a Client Component (with "use client" directive on top):

"use client"

import { useUIState } from "ai/rsc"

Let me know if this solves your issue!

Yes, this was it! Thanks a lot!

@RaduIm RaduIm closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants