Skip to content

refactor: avoid synchronous state updates in useEffect#1408

Merged
lusergit merged 2 commits intoedgehog-device-manager:mainfrom
JasminaPiric:refactor-auto-login
May 4, 2026
Merged

refactor: avoid synchronous state updates in useEffect#1408
lusergit merged 2 commits intoedgehog-device-manager:mainfrom
JasminaPiric:refactor-auto-login

Conversation

@JasminaPiric
Copy link
Copy Markdown
Contributor

@JasminaPiric JasminaPiric commented May 4, 2026

What this PR does / why we need it:

Fixes a cascading render warning caused by calling handleLogin synchronously inside a mounting effect.

Changes:

  • Decoupled the API login logic from the manual UI loading trigger.
  • Initialized isLoggingIn state based on URL parameters to prevent an immediate rerender on mount.
  • Extracted performLogin to handle the side effect without triggering synchronous state updates.

Additional documentation e.g. usage docs, diagrams, reviewer notes, etc.:


Thanks for sending a pull request! If this is your first time, here are some tips for you:
  1. You can take a look at our developer guide for an introduction on Edgehog development!
  2. Make sure to read CONTRIBUTING.md and CODE_OF_CONDUCT.md
  3. If the PR is unfinished or you're actively working on it, mark it as draft

When fixing existing issues, use github's syntax to link your pull request to it

fixes #<issue number>

We also have a syntax to signal dependencies to other open pull requests

depends on #<pr number>
depends on https://github.com/...

In case of stacked PRs, you may add the PR number in the last commit's title instead:

gitGraph
    commit id: "Current master"
    branch feat1
    checkout feat1
    commit id: "feat: add something"
    commit id: "feat: add something else (#100)"
    branch feat2
    checkout feat2
    commit id: "refactor: do something"
    commit id: "fix: solve issue"
    commit id: "feat: add a feature (#101)"
    branch feat3
    checkout feat3
    commit id: "feat: feat without pr number"
Loading

| datasource | package                          | from    | to      |
| ---------- | -------------------------------- | ------- | ------- |
| npm        | @formatjs/cli                    | 6.14.1  | 6.14.4  |
| npm        | @fortawesome/react-fontawesome   | 3.3.0   | 3.3.1   |
| npm        | @noble/hashes                    | 2.2.0   | 2.2.0   |
| npm        | @typescript-eslint/eslint-plugin | 8.58.1  | 8.59.1  |
| npm        | @typescript-eslint/parser        | 8.58.1  | 8.59.1  |
| npm        | @vitest/coverage-v8              | 4.1.4   | 4.1.5   |
| npm        | apexcharts                       | 5.10.6  | 5.10.6  |
| npm        | baseline-browser-mapping         | 2.10.18 | 2.10.24 |
| npm        | eslint-plugin-react-hooks        | 7.0.1   | 7.1.1   |
| npm        | jsdom                            | 29.0.2  | 29.1.1  |
| npm        | lucide-react                     | 1.8.0   | 1.14.0  |
| npm        | prettier                         | 3.8.2   | 3.8.3   |
| npm        | react-hook-form                  | 7.72.1  | 7.74.0  |
| npm        | react-router-dom                 | 7.14.0  | 7.14.2  |
| npm        | shadcn                           | 4.2.0   | 4.6.0   |
| npm        | vitest                           | 4.1.4   | 4.1.5   |
| npm        | zod                              | 4.3.6   | 4.4.1   |


Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Fixes a cascading render warning caused by calling `handleLogin`
synchronously inside a mounting effect.

Changes:
- Decoupled the API login logic from the manual UI loading trigger.
- Initialized `isLoggingIn` state based on URL parameters to prevent
  an immediate rerender on mount.
- Extracted `performLogin` to handle the side effect without
  triggering synchronous state updates.

Signed-off-by: Jasmina <jasmina.piric@secomind.com>
@JasminaPiric JasminaPiric force-pushed the refactor-auto-login branch from 63c3149 to 0871934 Compare May 4, 2026 12:20
@JasminaPiric JasminaPiric changed the title Refactor auto login to avoid setState in useEffect refactor: avoid synchronous state updates in useEffect May 4, 2026
@lusergit lusergit merged commit fd4da1d into edgehog-device-manager:main May 4, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants