2

I am getting this React error when running in dev mode with Snowpack

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

This import is where the error is comming from.

import { Button } from "antd"

This is the dependencies you need to know about.

 "dependencies": {
    "antd": "^4.5.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
  },
  "devDependencies": {
    "@snowpack/app-scripts-react": "^1.8.3",
    "snowpack": "^2.7.6"
  }

Do you have any idea how I can fix this?

I have tried so far these imports without luck.

import { Button } from "antd/lib/button"

and

import Button from "antd/lib/button"
jonjonson
  • 263
  • 2
  • 5
  • 16

2 Answers2

0

Antd Button accepts a prop type as a string, but it seems you are passing an object instead. Maybe you need to check again how you implemented your button.

Neves
  • 84
  • 1
  • 4
0

Antd Button accepts one of 5 STRING options : "default", "primary", "dashed", "text", "link". You are trying to pass an object instead.

import { Button } from 'antd';

Also, this works just fine. Using VScode would help with importing by simply type and VSCode will guide you to how to import the desired component

Kyle.Ng
  • 96
  • 1
  • 4