Skip to content

Commit 9820e05

Browse files
committed
Update i18n stubbing to avoid react deprecation warnings.
1 parent c0409ce commit 9820e05

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

setupJest.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ jest.mock('react-i18next', () => ({
4444
type: '3rdParty',
4545
},
4646
// this mock makes sure any components using the translate HoC receive the t function as a prop
47-
withTranslation: () => (Component) => {
48-
Component.defaultProps = { // eslint-disable-line no-param-reassign
49-
...Component.defaultProps, t: k => k,
50-
};
51-
return Component;
47+
withTranslation: () => (WrappedComponent) => {
48+
/**
49+
*
50+
*/
51+
const I18nAwareComponent = ({ t = (k => k), ...props }) => <WrappedComponent t={t} {...props} />; // eslint-disable-line react/prop-types
52+
53+
return I18nAwareComponent;
5254
},
5355
}));

0 commit comments

Comments
 (0)