[英]Property 'firebase' does not exist on type '{ children?: ReactNode; }' how to propperly annotate?
I'm providing my firebase object through a higher order component like this:我通过像这样的高阶组件提供我的 firebase object:
const FirebaseContextInterfaceLocal: FirebaseContextInterface = {
value: new Firebase()
}
ReactDOM.render(
<Router history={history}>
<FirebaseContext.Provider value={FirebaseContextInterfaceLocal}>
<App />
</FirebaseContext.Provider>
</Router>,
document.getElementById('root')
)
And after that I'm using it like this:之后我像这样使用它:
const ForgotPassword: React.FC = ({ firebase }) => {
}
export default withFirebase(ForgotPassword)
But I'm getting the following error:但我收到以下错误:
Property 'firebase' does not exist on type '{ children?: ReactNode; }'.
I'm trying to find out how to properly annotate this but I can't find any good explanation.我试图找出如何正确注释它,但我找不到任何好的解释。 Any help will be very appreciated!
任何帮助将不胜感激!
use value
key instead of firebase使用
value
键代替 firebase
const ForgotPassword: React.FC = ({ value }) => {
}
export default withFirebase(ForgotPassword)
or try to change the property of FirebaseContextInterfaceLocal
to:或尝试将
FirebaseContextInterfaceLocal
的属性更改为:
const FirebaseContextInterfaceLocal = {
firebase: new Firebase()
}
ReactDOM.render(
<Router history={history}>
<FirebaseContext.Provider firebase={FirebaseContextInterfaceLocal.firebase}>
<App />
</FirebaseContext.Provider>
</Router>,
document.getElementById('root')
)
So you can do this:所以你可以这样做:
const ForgotPassword: React.FC = ({ firebase }) => {
}
export default withFirebase(ForgotPassword)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.