Created
November 19, 2019 15:53
-
-
Save isabellachen/db7968a9e7b42f9b8a1524a5301789cc to your computer and use it in GitHub Desktop.
Extend component props with props from react router and react i18n with react typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { WithTranslation, withTranslation, useTranslation } from 'react-i18next'; | |
import { RouteComponentProps, withRouter } from 'react-router-dom'; | |
export type MyDemoProps = {} & RouteComponentProps & WithTranslation; | |
function MyDemoComponent({ | |
history, | |
t, | |
}: MyDemoProps) { | |
const [t] = useTranslation(); //alternatively, import translation function directly into component | |
return <div>DEMO COMPONENT</div> | |
} | |
export const MyDemo = withTranslation()( | |
withRouter(MyDemoComponent), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment