Skip to content

Commit

Permalink
refactor: resolve hook lint warning
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Nov 20, 2021
1 parent 952c57f commit 6ff01a8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/usePrismicPreviewResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ export const usePrismicPreviewResolver = (
args.client,
);

const [resolvedURL] = result;
const { navigate } = args;

React.useEffect(() => {
if (result[0] && args.navigate) {
args.navigate(result[0]);
if (resolvedURL && navigate) {
navigate(resolvedURL);
}
}, [result[0], args.navigate]);
}, [resolvedURL, navigate]);

return result;
};

0 comments on commit 6ff01a8

Please sign in to comment.