Skip to content

Commit dcff359

Browse files
committed
Bump version to 1.3.0 and rename sampArgs to sameArgs for consistency in Async component and useAsync hook
1 parent 7f79ad7 commit dcff359

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-client-async",
3-
"version": "1.2.2",
3+
"version": "1.3.0",
44
"main": "dist/lib.js",
55
"module": "dist/lib.js",
66
"files": ["dist/", "README.md", "LICENSE"],

src/libs/components/Async.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function Async<P>({
6161
// Create the options for the async function.
6262
const options = {
6363
autoLoad: true,
64-
sampArgs: sameArgs,
64+
sameArgs,
6565
} satisfies UseAsyncOptions<P>;
6666

6767
// Execute the async function and get the state.

src/libs/hooks/useAsync.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type UseAsyncObject<P> = {
3434
/**
3535
* Determine the arguments are the same.
3636
*/
37-
sampArgs: propsAreEqual<P>;
37+
sameArgs: propsAreEqual<P>;
3838
};
3939

4040
type UseAsyncOptions<P> = Partial<UseAsyncObject<P>>;
@@ -108,7 +108,7 @@ function useAsync<Args, Ret>(
108108
): UseAsyncReturn<Ret> {
109109
// Set default options
110110
options.autoLoad ??= false;
111-
options.sampArgs ??= sameProps;
111+
options.sameArgs ??= sameProps;
112112

113113
const [pending, setPending] = useState<boolean>();
114114
const [result, setResult] = useState<Ret>();
@@ -148,7 +148,7 @@ function useAsync<Args, Ret>(
148148

149149
// Check if no need to rerun the async function.
150150
const sameFn = fnRef.current === promiseFn;
151-
const sameArgs = options.sampArgs?.(argsRef.current, args);
151+
const sameArgs = options.sameArgs?.(argsRef.current, args);
152152
const sameRefresh = refreshRef.current === refresh;
153153
const notFirstRun = pending !== undefined || !options.autoLoad;
154154
const noChange = sameFn && sameArgs && sameRefresh && notFirstRun;

0 commit comments

Comments
 (0)