【问题标题】:react select error on upgrade: TypeError: dispatcher.useInsertionEffect is not a function升级时反应选择错误:TypeError:dispatcher.useInsertionEffect 不是函数
【发布时间】:2022-06-14 21:06:56
【问题描述】:

我刚刚更新了 react-select 库,我发现它不再起作用了。在the official site 上,我发现了这个升级指南,它对我没有帮助而且什么也没说。

我也检查了samples on their site,但它给了我同样的错误。

例如,我想做一个非常基本的可创建选择:

import AsyncCreatableSelect from 'react-select/async-creatable';

const promiseOptions = (inputValue: string) =>
  new Promise<any[]>((resolve) => {
    setTimeout(() => {
      console.log('searching...');
    }, 1000);
  });

const Select: React.FC = () => {
  return (
    <AsyncCreatableSelect
      cacheOptions
      defaultOptions
      loadOptions={promiseOptions}
    />
  );
};

我在项目中选择的所有其他选项都相同。你知道如何解决它吗?

我收到的错误如下:

我使用nextjs 12.1.2 react 18.0.0typescript 4.6.3react-select 5.2.2

【问题讨论】:

    标签: reactjs typescript next.js react-select


    【解决方案1】:

    问题似乎是我使用react 18.0.0react-dom 17.0.1

    为了解决上述问题,只需更新react-dom to 18.0.0

    【讨论】:

    • 以防万一,我不想升级到 react 18 或 react-dom 18。什么是修复?
    猜你喜欢
    • 1970-01-01
    • 2021-11-30
    • 2019-02-27
    • 1970-01-01
    • 1970-01-01
    • 2021-04-28
    • 2018-12-16
    • 1970-01-01
    相关资源
    最近更新 更多