Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v5] Remove Devtools warning #2466

Merged
merged 8 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
7 changes: 1 addition & 6 deletions src/middleware/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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" } } }
`,
Expand Down
5 changes: 0 additions & 5 deletions tests/devtools.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@ describe('If there is no extension installed...', () => {
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()
dbritto-dev marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading