@@ -7,8 +7,7 @@ type DeepPartial<T> = {
77export type StateStorage = {
88 getItem : ( name : string ) => string | null | Promise < string | null >
99 setItem : ( name : string , value : string ) => void | Promise < void >
10- // Note: This will be required in v4
11- removeItem ?: ( name : string ) => void | Promise < void >
10+ removeItem : ( name : string ) => void | Promise < void >
1211}
1312
1413type StorageValue < S > = { state : DeepPartial < S > ; version ?: number }
@@ -44,18 +43,6 @@ export type PersistOptions<
4443 deserialize ?: (
4544 str : string
4645 ) => StorageValue < PersistedState > | Promise < StorageValue < PersistedState > >
47- /**
48- * Prevent some items from being stored.
49- *
50- * @deprecated This options is deprecated and will be removed in the next version. Please use the `partialize` option instead.
51- */
52- blacklist ?: ( keyof S ) [ ]
53- /**
54- * Only store the listed properties.
55- *
56- * @deprecated This options is deprecated and will be removed in the next version. Please use the `partialize` option instead.
57- */
58- whitelist ?: ( keyof S ) [ ]
5946 /**
6047 * Filter the persisted value.
6148 *
@@ -189,14 +176,6 @@ export const persist =
189176 ...baseOptions ,
190177 }
191178
192- if ( options . blacklist || options . whitelist ) {
193- console . warn (
194- `The ${
195- options . blacklist ? 'blacklist' : 'whitelist'
196- } option is deprecated and will be removed in the next version. Please use the 'partialize' option instead.`
197- )
198- }
199-
200179 let hasHydrated = false
201180 const hydrationListeners = new Set < PersistListener < S > > ( )
202181 const finishHydrationListeners = new Set < PersistListener < S > > ( )
@@ -219,26 +198,13 @@ export const persist =
219198 get ,
220199 api
221200 )
222- } else if ( ! storage . removeItem ) {
223- console . warn (
224- `[zustand persist middleware] The given storage for item '${ options . name } ' does not contain a 'removeItem' method, which will be required in v4.`
225- )
226201 }
227202
228203 const thenableSerialize = toThenable ( options . serialize )
229204
230205 const setItem = ( ) : Thenable < void > => {
231206 const state = options . partialize ( { ...get ( ) } )
232207
233- if ( options . whitelist ) {
234- ; ( Object . keys ( state ) as ( keyof S ) [ ] ) . forEach ( ( key ) => {
235- ! options . whitelist ?. includes ( key ) && delete state [ key ]
236- } )
237- }
238- if ( options . blacklist ) {
239- options . blacklist . forEach ( ( key ) => delete state [ key ] )
240- }
241-
242208 let errorInSync : Error | undefined
243209 const thenable = thenableSerialize ( { state, version : options . version } )
244210 . then ( ( serializedValue ) =>
@@ -342,7 +308,7 @@ export const persist =
342308 }
343309 } ,
344310 clearStorage : ( ) => {
345- storage ?. removeItem ?. ( options . name )
311+ storage ?. removeItem ( options . name )
346312 } ,
347313 rehydrate : ( ) => hydrate ( ) as Promise < void > ,
348314 hasHydrated : ( ) => hasHydrated ,
0 commit comments