Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const config: ReturnType<typeof defineConfig> = defineConfig([
'object-shorthand': 'error',
'no-console': 'error',
eqeqeq: 'error',
'no-param-reassign': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
Expand All @@ -44,8 +45,10 @@ const config: ReturnType<typeof defineConfig> = defineConfig([
],
},
},

// CommonJS
{
files: ['**/*.cjs'],
files: ['**/*.{cjs,cts}'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion src/react/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from './use-debounce-state.ts';
export * from './use-dependent-ref.ts';
export * from './use-isomorphic-layout-effect.ts';
export * from './use-latest-ref.ts';
export * from './use-previous-state.ts';
export * from './use-stable-callback.ts';
export * from './use-mounted.ts';

Expand Down
8 changes: 7 additions & 1 deletion src/react/query/use-mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ export function useMutation<P, R = unknown>({
instance.events.removeEventListener('failed', onFailed);
instance.events.removeEventListener('changed', onChanged);
};
}, [instance, onSuccessRef, onErrorRef]);
}, [
instance,

// stable:
onSuccessRef,
onErrorRef,
]);

const mutate = useStableCallback(async (payload: P): Promise<R> => {
return await instance.execute(() => mutation(payload));
Expand Down
4 changes: 3 additions & 1 deletion src/react/use-intersection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ export function useIntersection<T extends Element>(
};
}, [
ref,
callbackRef,
readyOptions,
getObserver,

// stable:
callbackRef,

// eslint-disable-next-line react-hooks/exhaustive-deps
...extraDeps,
]);
Expand Down
6 changes: 5 additions & 1 deletion src/react/use-outside-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@ export function useOutsideClick<T extends Element>(
return () => {
document.documentElement.removeEventListener('click', handleClick, handleClickOptions);
};
}, [innerRef, callbackRef]);
}, [
// stable:
innerRef,
callbackRef,
]);
}
32 changes: 0 additions & 32 deletions src/react/use-previous-state.ts

This file was deleted.

4 changes: 3 additions & 1 deletion src/react/use-resize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ export function useResize<T extends Element>(
};
}, [
ref,
callbackRef,
getObserver,
readyOptions,

// stable:
callbackRef,

// eslint-disable-next-line react-hooks/exhaustive-deps
...extraDeps,
]);
Expand Down
8 changes: 7 additions & 1 deletion src/react/use-visual-viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ export function useVisualViewport({
sync();

return observe(visualViewport, sync);
}, [getVisualViewport, modeRef, handleChange]);
}, [
getVisualViewport,

// stable:
modeRef,
handleChange,
]);

return state;
}
17 changes: 17 additions & 0 deletions src/store/__test__/create-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,21 @@ describe('createStore', () => {
store.set(-100);
expect(spy.mock.callCount()).toBe(1);
});

test('methods should works without call context', () => {
const { get, set, subscribe } = createStore(1);

const spy = mock.fn();
const unsubscribe = subscribe(spy);

expect(get()).toBe(1);
expect(spy.mock.callCount()).toBe(0);

expect(set(123));
expect(spy.mock.callCount()).toBe(1);

unsubscribe();
expect(set(234));
expect(spy.mock.callCount()).toBe(1);
});
});