我正在通过这样的高级组件提供firebase对象:
const FirebaseContextInterfaceLocal: FirebaseContextInterface = {
value: new Firebase()
}
ReactDOM.render(
<Router history={history}>
<FirebaseContext.Provider value={FirebaseContextInterfaceLocal}>
<App />
</FirebaseContext.Provider>
</Router>,
document.getElementById('root')
)
然后我就这样使用它:
const ForgotPassword: React.FC = ({ firebase }) => {
}
export default withFirebase(ForgotPassword)
但是出现以下错误:
Property 'firebase' does not exist on type '{ children?: ReactNode; }'.
我正在尝试找出如何正确地对此进行注释,但是找不到任何好的解释。任何帮助将不胜感激!
答案 0 :(得分:0)
使用value
键而不是Firebase
const ForgotPassword: React.FC = ({ value }) => {
}
export default withFirebase(ForgotPassword)
或尝试将FirebaseContextInterfaceLocal
的属性更改为:
const FirebaseContextInterfaceLocal = {
firebase: new Firebase()
}
ReactDOM.render(
<Router history={history}>
<FirebaseContext.Provider firebase={FirebaseContextInterfaceLocal.firebase}>
<App />
</FirebaseContext.Provider>
</Router>,
document.getElementById('root')
)
因此您可以这样做:
const ForgotPassword: React.FC = ({ firebase }) => {
}
export default withFirebase(ForgotPassword)