Repository navigation
react-simplikit@1.0.0-rc.0
Pre-releaseMajor Changes
-
#549
4ee9b53Thanks @Antoliny0919! - Rename the useDoubleClick options click, doubleClick, and delay to onClick, onDoubleClick, and delayMs, respectively.Rename the initial value parameter of useList, useMap, and useSet from initialState to initialValue.
-
#552
d5a46beThanks @Antoliny0919! - Time-related options and parameters now includeMsin their names.
These option keys are renamed, so existing calls need to be updated:useDebouncedCallback:timeThreshold→debounceMsuseThrottledCallback:timeThreshold→throttleMsuseImpressionRef,ImpressionArea:timeThreshold→timeThresholdMsuseLongPress:delay→delayMsuseAvoidKeyboard:transitionDuration→transitionDurationMs
// before useDebouncedCallback({ onChange: setQuery, timeThreshold: 300 }); // after useDebouncedCallback({ onChange: setQuery, debounceMs: 300 });
The positional
waitparameter ofuseDebounce,useDebouncedValue,useThrottleanduseThrottledValueis nowdebounceMs/throttleMs. Calls likeuseDebounce(fn, 300)keep working. -
#599
144948eThanks @Choi-Jung-Hyeon! -useScrollDirection,useVisualViewport,useNetworkStatus,usePageVisibilityanduseSafeAreaInsetno longer initialize state from browser APIs. The first client render now returns the same value as the server, and the browser value arrives after mount. Before, rendering the value caused a hydration mismatch.The first render changes in client-only apps too:
Hook First render useScrollDirectionposition: 0useVisualViewportviewport: nulluseNetworkStatus{}usePageVisibility{ isVisible: true, visibilityState: 'visible' }useSafeAreaInset{ top: 0, bottom: 0, left: 0, right: 0 } -
#561
cf2626bThanks @hyesungoh! -subscribeKeyboardHeightnow defaultsimmediatetotrue, matchinguseKeyboardHeight. The callback runs once with the current keyboard height right after subscribing. Passimmediate: falseto keep the previous behavior.useKeyboardHeightanduseAvoidKeyboardare unaffected.// before: the callback waits for the first resize or scroll event subscribeKeyboardHeight({ callback }); // after: the callback also runs once right after subscribing subscribeKeyboardHeight({ callback }); // to keep the previous behavior subscribeKeyboardHeight({ callback, immediate: false });
-
#548
15aea8aThanks @Antoliny0919! - Replace theedgesoption inuseThrottleanduseThrottledCallbackwith optionalleadingandtrailingbooleans. Both default totrue, preserving the behavior when options are omitted. -
#532
78788e2Thanks @mnxmnz! -useBooleanState,useStorageStateanduseCounternow return[value, actions], matchinguseList,useMapanduseSet. The actions object keeps the same reference across renders.// before const [isOpen, setTrue, setFalse, toggle] = useBooleanState(false); const [token, setToken, refreshToken] = useStorageState<string>('token'); const { count, increment, decrement, reset, setCount } = useCounter(0); // after const [isOpen, { setTrue, setFalse, toggle }] = useBooleanState(false); const [token, { setValue, refresh }] = useStorageState<string>('token'); const [count, { increment, decrement, reset, setCount }] = useCounter(0);
useTogglekeeps its[value, toggle]signature and now declares its return type, so React 18 consumers no longer see the React 19ActionDispatchtype. -
#564
1a0a491Thanks @hyesungoh! -useStorageStatenow types its state asTinstead ofSerializable<T>, sonullin a union andinterfacetypes are kept. With<string | null>, the state was typedstringand is nowstring | null.Without
serializeranddeserializer, the value is stored as JSON and is now checked all the way down. Setting a value with aDate,Map, class instance, function,NaNorInfinityanywhere in it throws with its path. Before, such a nested value was silently changed or dropped: aDatebecame a string, aMapbecame{},NaNbecamenull, and a function disappeared.defaultValueis checked on mount, even when storage already holds a value.serializeranddeserializermust be passed together. A lone one is a type error and is ignored at runtime. When both are passed, the value is not checked, so aDatedefault works, and the callback parameters are typed fromdefaultValue.refreshnow reads storage again without writing to it. Before, it wrote the current value back: an empty key gotdefaultValue, an unreadable value was replaced withdefaultValueor removed, and a function stored withserializeranddeserializerwas run as an updater. Callrefreshwhendeserializerchanges what it returns for the same stored string.// before: the state was typed `string`, though it can be `null` const [token] = useStorageState<string | null>('token', { defaultValue: null, }); // after: the state is typed `string | null` const [token] = useStorageState<string | null>('token', { defaultValue: null, }); // before: stored as `{"at":"2026-01-01T00:00:00.000Z"}` and read back as a string setValue({ at: new Date() }); // after: throws "value.at is not JSON-serializable", so store a Date with both functions useStorageState('at', { defaultValue: new Date(), serializer: date => date.toISOString(), deserializer: text => new Date(text), });
-
#530
c6511efThanks @mnxmnz! -useIntervalanduseTimeoutnow take a single options object, with the callback asonTickandonTimeoutand the delay asdelayMs.useIntervalno longer accepts a bare number as its delay.// before useInterval(poll, 1000); useInterval(poll, { delay: 1000, immediate: true }); useTimeout(close, 3000); // after useInterval({ onTick: poll, delayMs: 1000 }); useInterval({ onTick: poll, delayMs: 1000, immediate: true }); useTimeout({ onTimeout: close, delayMs: 3000 });
-
#609
30b781dThanks @Choi-Jung-Hyeon! -useGeolocationnow restarts a watch started withstartTracking()whenenableHighAccuracy,maximumAgeortimeoutchanges, the same waymountBehavior: 'watch'already did. Before, the watch kept its original options untilstopTracking()andstartTracking()were called again. A stopped watch is not started again by an option change.
Minor Changes
-
#545
9d16479Thanks @hyesungoh! - AdduseCallbackOnce, which runs a callback only once until itsdepschange and has the same signature and behavior asuseCallbackOncePerRender.useCallbackOncePerRenderis now deprecated in favor ofuseCallbackOnceand still works as an alias of it. The second example now listsuserIdin the effect's dependencies, because the returned function keeps the same reference and an effect keyed only on it does not run again whendepschange. -
#558
71c1a07Thanks @Antoliny0919! - AdduseDebouncedStateanduseThrottledState, which manage state and return debounced and throttled setters, respectively. Both hooks supportleadingandtrailingoptions and cancel pending updates on unmount or when timing options change. -
#546
83ae1a3Thanks @hyesungoh! - AddusePageVisibilityEffect, which runs a callback when the page visibility changes and pairs by name withusePageVisibility, which returns the same value as state.useVisibilityEventis deprecated in favor ofusePageVisibilityEffectand still works as before, since it is now the same function under its old name. This reverses the note from #435 thatuseVisibilityEventis no longer deprecated. It is deprecated again because of the rename, not because it is going away: it keeps working throughout v1 and may be removed in a later major version.
Patch Changes
- #544
917b09bThanks @hyesungoh! - Rename the comparison parameter ofusePreviousandusePreservedReferencetoequalityFn, matchinguseControlledState.usePreviousnow compares withObject.isby default, so renderingNaNagain no longer overwrites the previous value, and a change between0and-0is detected.