所有.
我正在尝试在我的nextjs应用程序中实现react-draft-wysiwyg库。这是我的代码(this solution):
import dynamic from 'next/dynamic'
import { EditorProps } from 'react-draft-wysiwyg'
const ReactDraftWysiwyg = dynamic<EditorProps>(() => import('react-draft-wysiwyg').then((mod) => mod.Editor), {
ssr: false,
})
export default ReactDraftWysiwyg
但是当我运行npm run build
时,我得到了这个错误:
Type error: Argument of type '() => Promise<ComponentClass<EditorProps, any> | FunctionComponent<EditorProps> | ComponentModule<EditorProps> | typeof Editor>' is not assignable to parameter of type 'DynamicOptions<EditorProps> | Loader<EditorProps>'.
Type '() => Promise<ComponentClass<EditorProps, any> | FunctionComponent<EditorProps> | ComponentModule<EditorProps> | typeof Editor>' is not assignable to type '() => LoaderComponent<EditorProps>'.
Type 'Promise<ComponentClass<EditorProps, any> | FunctionComponent<EditorProps> | ComponentModule<EditorProps> | typeof Editor>' is not assignable to type 'LoaderComponent<EditorProps>'.
Type 'ComponentClass<EditorProps, any> | FunctionComponent<EditorProps> | ComponentModule<EditorProps> | typeof Editor' is not assignable to type 'ComponentType<EditorProps> | ComponentModule<EditorProps>'.
Type 'typeof Editor' is not assignable to type 'ComponentType<EditorProps> | ComponentModule<EditorProps>'.
Type 'typeof Editor' is not assignable to type 'ComponentClass<EditorProps, any>'.
Types of property 'contextType' are incompatible.
Type 'import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").Context<any> | undefined' is not assignable to type 'React.Context<any> | undefined'.
Type 'import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").Context<any>' is not assignable to type 'React.Context<any>'.
The types of 'Provider.propTypes' are incompatible between these types.
Type 'import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").WeakValidationMap<import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").ProviderProps<any>> | undefined' is not assignable to type 'React.WeakValidationMap<React.ProviderProps<any>> | undefined'.
Type 'import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").WeakValidationMap<import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").ProviderProps<any>>' is not assignable to type 'React.WeakValidationMap<React.ProviderProps<any>>'.
Types of property 'children' are incompatible.
Type 'import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").Validator<import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").ReactNode> | undefined' is not assignable to type 'React.Validator<React.ReactNode> | undefined'.
Type 'import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").Validator<import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").ReactNode>' is not assignable to type 'import("/home/iblasterus/projects/coral/frontend/node_modules/@types/prop-types/index").Validator<React.ReactNode>'.
Type 'import("/home/iblasterus/projects/coral/frontend/node_modules/@types/react-transition-group/node_modules/@types/react/ts5.0/index").ReactNode' is not assignable to type 'React.ReactNode'.
Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.
我很为难。需要帮助。谢谢
1条答案
按热度按时间goqiplq21#
这是因为我使用yarn作为应用程序的加载依赖项。当我使用npm时,这个问题解决了,我的应用程序成功构建。