我正在尝试使用 Fable 在 F# 中编写一个 React 组件,但在引用必要的库时遇到了麻烦。我得到的编译错误是:
- 未定义命名空间“React”。(“公开”陈述)
- PureStatelessComponent 类型未定义。
这是我的代码
module ContactInfoComponent
open Fable.Core
open Fable.Core.JsInterop
open Fable.Import
open Fable.Import.Browser
open Fable.React
open Fable.React.Helpers
type ContactInfoProps = {
Name : string
}
type ContactInfoComponent(initialProps) =
inherit PureStatelessComponent<ContactInfoProps>(initialProps)
override this.render() =
div [] [
str "Name: "
input [Type "text" Id "txtName"]
]
这是我在 package.json 中的依赖项:
"devDependencies": {
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
},
"dependencies": {
"@babel/core": "^7.8.7",
"fable-compiler": "^2.4.18",
"fable-loader": "^2.1.8",
"fable-core": "^0.7.30",
"fable-powerpack": "0.0.20",
"fable-react": "^0.8.6",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
}
<ItemGroup>
<Reference Include="node_modules/fable-core/Fable.Core.dll" />
<Reference Include="node_modules/fable-powerpack/Fable.PowerPack.dll" />
<Reference Include="node_modules/fable-react/Fable.React.dll" />
<PackageReference Include="Fable.Browser.Dom" Version="1.0.0" />
</ItemGroup>
我能做些什么来解决这些编译错误?