[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
This commit is contained in:
Charles Kornoelje 2024-04-15 21:58:58 -04:00 committed by GitHub
parent 36d4734689
commit fe47d3e6c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 22 deletions

View File

@ -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'

View File

@ -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" } } }
`,

View File

@ -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...', () => {