Class based components directly donot support Hooks.
Read React-FAQ
You can create a Higher Order Component
, like this:
import React from 'react';
import { useFirebaseAuthentication} from '../hooks/useFirebaseAuthentication';
export const withFireBaseAuthHookHOC = (Component: any) => {
return (props: any) => {
const authUser = useFirebaseAuthentication();
return <Component authUser ={authUser} {...props} />;
};
};
Now just wrap your class based component with this HOC
.
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…