Skip to content

Commit

Permalink
fix(ssr): fix ssr conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael A Tomcal committed Aug 28, 2020
1 parent d65c36f commit 40185d0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions __tests__/makeServerFetchye.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('makeServerFetchye', () => {
"ok": true,
"status": 200,
},
"error": undefined,
"error": null,
}
`);
});
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('makeServerFetchye', () => {
"ok": true,
"status": 200,
},
"error": undefined,
"error": null,
}
`);
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/runAsync.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('runAsync', () => {
"fake": true,
},
},
"error": undefined,
"error": null,
}
`);
});
Expand Down
2 changes: 1 addition & 1 deletion src/runAsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const runAsync = async ({
} else {
dispatch(actions.errorAction({ hash: computedKey.hash, error: requestError }));
}
return { data, error: requestError };
return { data, error: requestError || null };
};

export default runAsync;
4 changes: 2 additions & 2 deletions src/useFetchye.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import { useFetchyeContext } from './useFetchyeContext';
import { defaultMapOptionsToKey } from './defaultMapOptionsToKey';

const getData = (data, isFirstRender, options) => {
if (!data && isFirstRender.current) {
if (!data && !isFirstRender.current) {
return options?.initialData?.data;
}
return data;
};

const getError = (error, isFirstRender, options) => {
if (!error && isFirstRender.current) {
if (!error && !isFirstRender.current) {
return options?.initialData?.error;
}
return error;
Expand Down

0 comments on commit 40185d0

Please sign in to comment.