chore: show deprecated message only in DEV (#1523)

This commit is contained in:
Daishi Kato 2023-01-10 20:12:29 +09:00 committed by GitHub
parent a1d4034907
commit f607260a64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 12 deletions

View File

@ -502,9 +502,11 @@ const persistImpl: PersistImpl = (config, baseOptions) => {
'serialize' in baseOptions ||
'deserialize' in baseOptions
) {
console.warn(
'[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Please use `storage` option instead.'
)
if (__DEV__) {
console.warn(
'[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Please use `storage` option instead.'
)
}
return oldImpl(config, baseOptions)
}
return newImpl(config, baseOptions)

View File

@ -91,8 +91,10 @@ export const create = (<T>(createState: StateCreator<T, [], []> | undefined) =>
* @deprecated Use `import { create } from 'zustand'`
*/
export default ((createState: any) => {
console.warn(
"[DEPRECATED] default export is deprecated, instead import { create } from'zustand'"
)
if (__DEV__) {
console.warn(
"[DEPRECATED] default export is deprecated, instead import { create } from'zustand'"
)
}
return create(createState)
}) as Create

View File

@ -52,8 +52,10 @@ export function shallow<T>(objA: T, objB: T) {
* @deprecated Use `import { shallow } from 'zustand/shallow'`
*/
export default ((objA, objB) => {
console.warn(
"[DEPRECATED] default export is deprecated, instead import { shallow } from'zustand/shallow'"
)
if (__DEV__) {
console.warn(
"[DEPRECATED] default export is deprecated, instead import { shallow } from'zustand/shallow'"
)
}
return shallow(objA, objB)
}) as typeof shallow

View File

@ -109,9 +109,11 @@ export const createStore = ((createState) =>
* @deprecated Use `import { createStore } from ...`
*/
export default ((createState) => {
console.warn(
'[DEPRECATED] default export is deprecated, instead import { createStore } ...'
)
if (__DEV__) {
console.warn(
'[DEPRECATED] default export is deprecated, instead import { createStore } ...'
)
}
return createStore(createState)
}) as CreateStore