From fe47d3e6c6671dbfb9856fda52cb5a3a855d97a6 Mon Sep 17 00:00:00 2001 From: Charles Kornoelje <33156025+charkour@users.noreply.github.com> Date: Mon, 15 Apr 2024 21:58:58 -0400 Subject: [PATCH] [v5] Remove Devtools warning (#2466) * chore: remove devtools extension warning * docs: add devtools link to readme * chore: remove unused test * chrome: remove unused tests * chore: remove unused test * Revert "chore: remove unused test" This reverts commit 0fa2a75f4936d960f703bf19e8f3505962cd628e. * update test name --- readme.md | 2 ++ src/middleware/devtools.ts | 7 +------ tests/devtools.test.tsx | 17 +---------------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/readme.md b/readme.md index 3ee0ee3558..52b2e723d4 100644 --- a/readme.md +++ b/readme.md @@ -360,6 +360,8 @@ const useGrumpyStore = create(redux(reducer, initialState)) ## Redux devtools +Install the [Redux DevTools Chrome extension](https://chromewebstore.google.com/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd) to use the devtools middleware. + ```jsx import { devtools } from 'zustand/middleware' diff --git a/src/middleware/devtools.ts b/src/middleware/devtools.ts index 3d018eec09..197e89c38b 100644 --- a/src/middleware/devtools.ts +++ b/src/middleware/devtools.ts @@ -158,11 +158,6 @@ const devtoolsImpl: DevtoolsImpl = } if (!extensionConnector) { - if (import.meta.env?.MODE !== 'production' && enabled) { - console.warn( - '[zustand devtools middleware] Please install/enable Redux devtools extension', - ) - } return fn(set, get, api) } @@ -269,7 +264,7 @@ const devtoolsImpl: DevtoolsImpl = if (Object.keys(action.state as S).length !== 1) { console.error( ` - [zustand devtools middleware] Unsupported __setState action format. + [zustand devtools middleware] Unsupported __setState action format. When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(), and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } } `, diff --git a/tests/devtools.test.tsx b/tests/devtools.test.tsx index c2d6367b93..805a0b22c7 100644 --- a/tests/devtools.test.tsx +++ b/tests/devtools.test.tsx @@ -149,25 +149,10 @@ describe('If there is no extension installed...', () => { }).not.toThrow() }) - it('does not warn if not enabled', async () => { + it('does not warn', async () => { createStore(devtools(() => ({ count: 0 }))) expect(console.warn).not.toBeCalled() }) - - it('[DEV-ONLY] warns if enabled in dev mode', async () => { - createStore(devtools(() => ({ count: 0 }), { enabled: true })) - expect(console.warn).toBeCalled() - }) - - it.skip('[PRD-ONLY] does not warn if not in dev env', async () => { - createStore(devtools(() => ({ count: 0 }))) - expect(console.warn).not.toBeCalled() - }) - - it.skip('[PRD-ONLY] does not warn if not in dev env even if enabled', async () => { - createStore(devtools(() => ({ count: 0 }), { enabled: true })) - expect(console.warn).not.toBeCalled() - }) }) describe('When state changes...', () => {