mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
refactor: move logger initialization outside of useCliStatus function
- Moved the logger initialization to the top of the file for better readability and to avoid re-initialization on each function call. - This change enhances the performance and clarity of the code in the useCliStatus hook. - fix infinite loop calling caused by rerender because of logger
This commit is contained in:
@@ -7,6 +7,7 @@ interface UseCliStatusOptions {
|
|||||||
setCliStatus: (status: any) => void;
|
setCliStatus: (status: any) => void;
|
||||||
setAuthStatus: (status: any) => void;
|
setAuthStatus: (status: any) => void;
|
||||||
}
|
}
|
||||||
|
const logger = createLogger('CliStatus');
|
||||||
|
|
||||||
export function useCliStatus({
|
export function useCliStatus({
|
||||||
cliType,
|
cliType,
|
||||||
@@ -15,7 +16,6 @@ export function useCliStatus({
|
|||||||
setAuthStatus,
|
setAuthStatus,
|
||||||
}: UseCliStatusOptions) {
|
}: UseCliStatusOptions) {
|
||||||
const [isChecking, setIsChecking] = useState(false);
|
const [isChecking, setIsChecking] = useState(false);
|
||||||
const logger = createLogger('CliStatus');
|
|
||||||
|
|
||||||
const checkStatus = useCallback(async () => {
|
const checkStatus = useCallback(async () => {
|
||||||
logger.info(`Starting status check for ${cliType}...`);
|
logger.info(`Starting status check for ${cliType}...`);
|
||||||
|
|||||||
Reference in New Issue
Block a user