简体   繁体   English

react18 + react-datepicker@4.8.0(node18) 无法显示组件Datepicker

[英]react18 + react-datepicker@4.8.0(node18) can not display component Datepicker

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:object。

I just make on example from documentation, but I get an error that above:我只是从文档中举个例子,但我得到了上面的错误:

import React, { useState } from 'react';

import DatePicker from 'react-datepicker';

import 'react-datepicker/dist/react-datepicker.css';

const Example = () => {
  const [startDate, setStartDate] = useState(new Date());

  return (
    <DatePicker
      selected={startDate}
      onChange={(date: Date) => setStartDate(date)}
    />
  );
};

maybe someone faced a similar problem, I will be grateful for help也许有人遇到过类似的问题,我将不胜感激

there is no issue in the 'react-datepicker' package. I have checked the above code it is working correctly. 'react-datepicker' package 没有问题。我已经检查了上面的代码它是否正常工作。

I also faced the same issue so when I checked my code I had written one function outside the primary function. So that's why this issue comes you can check your other file code.我也遇到了同样的问题,所以当我检查我的代码时,我在主要的 function 之外写了一个 function。所以这就是为什么出现这个问题你可以检查你的其他文件代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React18 中的 SSR 使用 renderToPipableStream - 服务器生成的 HTML 和客户端 HTML 文件 UI 不匹配 - SSR in React18 using renderToPipableStream - Server Generated HTML and Client Side HTML file UI are not matching 找不到模块:无法在 next.js 12.1.5 中使用节点 16 的反应 18 解析“再生器运行时” - Module not found: Can't resolve 'regenerator-runtime' in next js 12.1.5 with react 18 with node 16 升级以响应 typescript 中的 18 个问题 - Upgarding to react 18 issues in typescript 创建 React App 不适用于节点 18 LTS 版本 - Create React App not working on node 18 LTS version 在 React Native 项目上将节点和 npm 从 npm 6 更新为 8,将节点 14 更新为 16 或 18,在 ENOENT 上失败 - updating node and npm from npm 6 to 8 and node 14 to 16 or 18 on a react native project , fails on ENOENT 升级到 react 18 会导致 package 依赖错误 - Upgrading to react 18 results in package dependencies errors Express React i18n:无法获取/locales/resources.json(JS/TS/节点) - Express React i18n: Cannot GET /locales/resources.json (JS / TS / Node) 下一个身份验证与 React 18 冲突 - conflict next-auth with react 18 如何清除 react-multiple-datepicker 中的值? - how to clear the values in react-multiple-datepicker? 为什么我的翻译不适用于 react-i18next? - Why is my translations not working with react-i18next?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM