From 6434fd07784b4cddc886c5759b34dbbdab273006 Mon Sep 17 00:00:00 2001 From: Tomas Nygren Date: Tue, 18 Aug 2020 11:13:00 +1000 Subject: [PATCH] fix: react-hooks/exhaustive-deps warnings do not appear when running Co-authored-by: Matteo Vivona --- .eslintrc.js | 1 + .../network-status/NetworkStatusMessage.test.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 07674dd3f8..2b93e382d8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,6 +6,7 @@ module.exports = { 'jest/globals': true, }, extends: [ + 'react-app', 'airbnb', 'eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', diff --git a/src/__tests__/shared/components/network-status/NetworkStatusMessage.test.tsx b/src/__tests__/shared/components/network-status/NetworkStatusMessage.test.tsx index 87cf13246a..cf36ac4e1c 100644 --- a/src/__tests__/shared/components/network-status/NetworkStatusMessage.test.tsx +++ b/src/__tests__/shared/components/network-status/NetworkStatusMessage.test.tsx @@ -1,3 +1,4 @@ +import { renderHook } from '@testing-library/react-hooks' import { render, shallow } from 'enzyme' import React from 'react' @@ -16,10 +17,9 @@ const englishTranslationsMock = { 'networkStatus.online': 'you are back online', } -const useTranslationReturnValue = useTranslation() as any -useTranslationReturnValue.t = (key: keyof typeof englishTranslationsMock) => - englishTranslationsMock[key] -const { t } = useTranslationReturnValue +const { result } = renderHook(() => useTranslation() as any) +result.current.t = (key: keyof typeof englishTranslationsMock) => englishTranslationsMock[key] +const { t } = result.current describe('NetworkStatusMessage', () => { it('returns null if the app has always been online', () => {