tiagobento commented on code in PR #2099:
URL:
https://github.com/apache/incubator-kie-tools/pull/2099#discussion_r1443097330
##########
packages/chrome-extension/src/app/components/common/customEffects.ts:
##########
@@ -60,5 +60,5 @@ export function useInitialAsyncCallEffect<T>(promise: () =>
Promise<T>, callback
return () => {
canceled = true;
};
- }, []);
+ }, [callback, promise]);
Review Comment:
This looks correct now, but we need to make sure the arguments are being
memoized.. See `IsolatedPrEditor`.. We need to wrap the first argument there in
a `useCallback` otherwise this effect will run multiple times.
##########
packages/chrome-extension/src/app/github/api.ts:
##########
@@ -39,7 +38,10 @@ export function fetchFile(
.then((res) => (contentType === ContentType.BINARY ? (res.data as
any).content : atob((res.data as any).content)))
.catch((e) => {
console.debug(`Error fetching ${path} with Octokit. Fallback is
'raw.githubusercontent.com'.`);
- return
fetch(`https://raw.githubusercontent.com/${org}/${repo}/${commitSHA}/${path}`).then((res)
=>
+ const modifiedRawGithubUserContentUrl = new URL(
+ `https://raw.githubusercontent.com/${org}/${repo}/${ref}/${path}`
+ );
Review Comment:
I would inline this variable as well to avoid having to give it a name.
##########
packages/chrome-extension/src/app/components/common/customEffects.ts:
##########
@@ -27,7 +27,7 @@ export function useEffectAfterFirstRender(func: () =>
ReturnType<EffectCallback>
} else {
firstRender.current = false;
}
- }, deps);
+ }, [func]);
Review Comment:
This one is not right as well... as the `deps` parameter actually is what
should be used. I think the correct would be:
```suggestion
}, [func, ...deps]);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]