aws-amplify / amplify-ui

Amplify UI is a collection of accessible, themeable, performant React (and more!) components that can connect directly to the cloud.
https://ui.docs.amplify.aws
Apache License 2.0
896 stars 285 forks source link

Input Component Failing to Import in Next JS #4503

Closed nicholasrobertson closed 1 year ago

nicholasrobertson commented 1 year ago

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Other

How is your app built?

Next.JS

What browsers are you seeing the problem on?

Chrome

Which region are you seeing the problem in?

ap-southeast-2

Please describe your bug.

When using the following

import { Input } from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';

export default function Home() {
  return <Input/>
}

I receive the following error

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `Home`.

What's the expected behaviour?

The component should import and render fine. Other components seem to work fine in this project

Help us reproduce the bug!

Create a NextJs project

Next.js v13.1.6

import { Input } from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';

export default function Home() {
  return <Input/>
}

Code Snippet

No response

Console log output

No response

Additional information and screenshots

Package.json

{
  "name": "unit",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@apollo/client": "^3.7.10",
    "@aws-amplify/ui-react": "^4.6.5",
    "@fontsource/inter": "^4.5.15",
    "ai": "^2.1.15",
    "aws-amplify": "^5.3.11",
    "eslint-config-next": "^13.1.6",
    "graphql": "^16.6.0",
    "next": "^13.1.6",
    "openai-edge": "^1.1.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-hook-form": "^7.45.0",
    "svelte": "^4.2.1"
  }
}
hbuchel commented 1 year ago

Hi @nicholasrobertson The Input primitive was released with @aws-amplify/ui-react@5.3.0 Please try updating your dependency.

reesscot commented 1 year ago

@nicholasrobertson Closing out as the Input primitive is available starting in @aws-amplify/ui-react@5.3.0. Please open a new issue if upgrading doesn't solve your problem.

nicholasrobertson commented 9 months ago

Updating to version 5 worked, thank you @hbuchel and @reesscot , much appreciated :)