Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore : Clean hook usage in UseLunatic #388

Open
wants to merge 2 commits into
base: v3-master
Choose a base branch
from

Conversation

Grafikart
Copy link
Collaborator

Some hooks had bad pratices (setter in useEffect) that triggers unecessary renders.

@Grafikart Grafikart force-pushed the chore/clean-hooks-orchestrator branch 2 times, most recently from 02b6f64 to e47083a Compare September 11, 2023 08:34
@Grafikart Grafikart added easy-review quality Improves code quality labels Sep 11, 2023
@Grafikart Grafikart requested a review from ddecrulle September 11, 2023 09:39
@Grafikart Grafikart force-pushed the chore/clean-hooks-orchestrator branch from e47083a to ab18589 Compare September 20, 2023 14:30
@@ -1,4 +1,4 @@
import { useEffect, useState, PropsWithChildren, useCallback } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ type PropsWithChildren, ...}`

return personalization.reduce((acc, { name, value }) => {
return { ...acc, [name]: value };
}, {});
): Record<string, string | number | boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why return type is not infered ?

return { ...acc, [name]: value };
}, {});
): Record<string, string | number | boolean> {
return Object.fromEntries(personalization.map((p) => [p.name, p.value]));
}

export function UseLunatic(props: PropsWithChildren<OrchestratorProps>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooks must be uncapitalized in React ?

@sonarcloud
Copy link

sonarcloud bot commented Sep 20, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Base automatically changed from v3-develop to v3-master December 18, 2023 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy-review quality Improves code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants