Skip to content

[Meta] React@18 legacy mode upgrade QA #203114

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

Closed
30 of 36 tasks
Dosant opened this issue Dec 5, 2024 · 15 comments
Closed
30 of 36 tasks

[Meta] React@18 legacy mode upgrade QA #203114

Dosant opened this issue Dec 5, 2024 · 15 comments
Assignees
Labels
Meta React@18 Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)

Comments

@Dosant
Copy link
Contributor

Dosant commented Dec 5, 2024

Shared UX team is working on React@18 upgrade.

We plan to upgrade in 2 phases:

  1. Phase 1: Upgrade React packages to version 18 and keep running in Legacy mode, which should behave mostly similarly to React@17.
  2. Phase 2: Gradually migrate to Concurrent mode.

We’re almost ready to complete phase 1:

  • All types breaking changes have been addressed and Kibana is already using @types/react@18 in main
  • We’ve fixed unit tests breaking changes in main. Kibana is already using the latest @testing-library/react in main and we've fixed the breaking changes that are backward compatible and can be merged separately.
  • We’ve addressed all runtime issues found by functional tests and CI functional tests are now green when running with React@18.

The final PR for the React@18 packages upgrade is minimal—it only updates the packages and includes a few snapshot updates. While we don’t expect any immediate benefits from this upgrade, it is an important step toward migrating to concurrent rendering, which will unlock performance improvements and new APIs.

Kibana’s UI functional tests coverage and a small number of discovered runtime issues give us a lot of confidence, but we need teams that own any UI to help with QA before the merge to discover any critical UI issues that could have been missed by functional testing.

  • Please mark your team's sub-tasks as Completed when finished
  • Feel free to convert to sub-issue
  • Please raise blockers in the comments or in the #kibana-react-18 channel
  • 📆 If not blocking issues raised, we plan to merge on Monday, March 3
  • Feel free to update point of contact (it was copied from [Meta] EUI Visual Refresh integration and QA #199715) or remove the sub-issue if the not relevant for you team

If you have questions, please do not hesitate to reach out to the shared-ux team in #kibana-react-18 channel

Per team sub-task list (feel free to convert to sub-issue)

Mark [x] when Completed when finished testing your UIs with React@18

How to test

Testing can be done locally by using the PR (#209337) or from main with REACT_18=true ENV flag:

REACT_18=true yarn kbn bootstrap
REACT_18=true yarn start

You can also use cloud or serverless deployment from that PR.

Tip

  • Locally you can tell that you're running React@18 by the following message in the console: Kibana is built with and running React@18.2.0, muting legacy root warning.
  • When deployed and when having React Dev Tools extension you can check the version with __REACT_DEVTOOLS_GLOBAL_HOOK__.renderers.get(1).version in console

What to look for

Tip

Look for blank screens, error splash screens, unresponsive pages, new errors in the console, unpredictable UI behavior (like laggy text inputs that skip letters when typing fast). You can also review the list of addressed runtime issues discovered by functional tests in the section below

Runtime issues discovered by functional tests

The ID scheme that is produced by new useId hook returns IDs that look like :S1:, but : is not a valid character for CSS identifiers, so code like breaks:

const id = useId();
document.querySelector(id); // fails with `SyntaxError: ':id:' is not a valid selector.`
- useEffect(() => fetch(), []); // fails with an error, likely blank screen
+ useEffect(() => {
+ fetch()
+ }, []);

This pattern for controlled inputs breaks when running in legacy mode where it worked fine with React@17

useEffect(() => {
    if (inputRef.current) {
      inputRef.current.value = value;
    }
  }, [value]);

Consider situation like this. This is a controlled input but the value is updated async. With React@18 we noticed that the lag could become worse as we were seeing some new flaky tests because of this where input skips letter:

export function App() {
  const [value, setValue] = useState("");

  return (
      <input
        type="text"
        value={value}
        onChange={(e) => {
          const value = e.currentTarget.value;
          setTimeout(() => {
            setValue(value);
          }, 0);
        }}
      />
  );
}

In this case a state reducer was not pure as it threw an error when executed the first time (and not at later times). React@17 executed that reducer twice so error didn't propagate to the UI, wheres in React@18 that behavior has changed and we saw that error on UI. More details in the PR.

useEffect deps updates caused infinite loop but for some reason it stabilized with React@17, but not with React@18

Issues discovered outside of functional tests

... Please add any issues that are found outside of functional tests ...

If you have questions, please do not hesitate to reach out to the shared-ux team in #kibana-react-18 channel

@Dosant Dosant added Meta React@18 Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) labels Dec 5, 2024
@Dosant Dosant self-assigned this Dec 5, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@smith
Copy link
Contributor

smith commented Feb 7, 2025

[React@18 QA] @elastic/observability-ui @smith / @MiriamAparicio

@Dosant I've checked off this line. All parts of the Observability UI should be accounted for with the individual issues for individual teams.

@TinaHeiligers
Copy link
Contributor

@Dosant Core-review complete with no significant findings.

@szwarckonrad
Copy link
Contributor

szwarckonrad commented Feb 20, 2025

@Dosant
I have tested the Defend Workflow functionalities on the final PR, confirming via React DevTools that the React version is 18.2. I haven’t noticed any regressions in the core functionalities we own—everything renders correctly and behaves as expected. Detailed steps can be found in the subticket I’ve marked as completed at this point.

@kpollich
Copy link
Member

I completed the testing for the Fleet + Integrations plugins and all worked as expected. Thanks for the great work here!

@kapral18
Copy link
Contributor

We completed testing for threat-hunting thanks as well.

@peteharverson
Copy link
Contributor

I completed a manual test of all the pages in the ML plugin, and the transform pages under Stack Management. All looked good and didn't spot any regressions. Checklist of pages tested can be found in #209748. Thanks for all the work here @Dosant .

@klacabane
Copy link
Contributor

Completed testing for entities and streams program. Everything is working as expected

@jasonrhodes
Copy link
Member

We've completed the React 18 manual testing for our areas in @elastic/obs-ux-management-team

@markov00
Copy link
Member

markov00 commented Mar 3, 2025

Test completed across Kibana Visualizations components, nothing concerning this upgrade have been found

delanni pushed a commit that referenced this issue Mar 3, 2025
## Summary

This PR upgrades React packages to version 18, while keeping Kibana
running in Legacy mode (`ReactDOM.render`). This is the first phase of
the React@18 upgrade; the second phase will gradually migrate Kibana to
Concurrent mode (`createRoot`) (exact plan is tbd).

Upgrade is intended to be non-breaking and behave just like React@17,
but it still requires thorough testing from all teams that own UI to
discover any potential critical UI issues. The testing was done in
#203114.

Most of the breaking work was completed in previous PRs and this PR only
includes minor breaking jest tests tweaks / snapshots updates

### Backports:

- This won't be backported to 9.0 
- We will discuss if we should backport this to 8.x

### Risks 

Kibana’s UI functional tests coverage and significant manual testing
that was done by a lot of teams in
#203114 gives us a lot of
confidence.

However, since this was a large internal change for React they still
could be issues hidden in "remote" parts of UIs, think of blank screens,
error splash screens, unresponsive pages, new errors in the console,
unpredictable UI behavior (like laggy text inputs that skip letters when
typing fast).

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Konrad Szwarc <konrad.szwarc@elastic.co>
@nikitaindik
Copy link
Contributor

Rule Management team testing completed. No issues found 🚀
Tested our features on main with React v18 enabled.

Also, removed the @elastic/security-detections-response team from the list since it's just a grouping for the Rule Management and the Detection Engine teams. Both are already in the list.

@Dosant
Copy link
Contributor Author

Dosant commented Mar 3, 2025

The React@18 upgrade PR was merged into main today.

Thanks to everyone who helped with testing!

I'll keep this issue open for a week or two to follow up on any issues that may arise

@stratoula
Copy link
Contributor

Amazing job @Dosant and team!

CAWilson94 pushed a commit to CAWilson94/kibana that referenced this issue Mar 22, 2025
## Summary

This PR upgrades React packages to version 18, while keeping Kibana
running in Legacy mode (`ReactDOM.render`). This is the first phase of
the React@18 upgrade; the second phase will gradually migrate Kibana to
Concurrent mode (`createRoot`) (exact plan is tbd).

Upgrade is intended to be non-breaking and behave just like React@17,
but it still requires thorough testing from all teams that own UI to
discover any potential critical UI issues. The testing was done in
elastic#203114.

Most of the breaking work was completed in previous PRs and this PR only
includes minor breaking jest tests tweaks / snapshots updates

### Backports:

- This won't be backported to 9.0 
- We will discuss if we should backport this to 8.x

### Risks 

Kibana’s UI functional tests coverage and significant manual testing
that was done by a lot of teams in
elastic#203114 gives us a lot of
confidence.

However, since this was a large internal change for React they still
could be issues hidden in "remote" parts of UIs, think of blank screens,
error splash screens, unresponsive pages, new errors in the console,
unpredictable UI behavior (like laggy text inputs that skip letters when
typing fast).

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Konrad Szwarc <konrad.szwarc@elastic.co>
@Dosant
Copy link
Contributor Author

Dosant commented Apr 7, 2025

@rbrtj found one issue #217291

it is the same as one we saw previously mentioned in the description:

useEffect must return undefined or destroy function, objects no longer allowed #195421

- useEffect(() => fetch(), []); // fails with an error, likely blank screen
+ useEffect(() => {
+ fetch()
+ }, []);

So far this is the only issue I've heard of, which sounds great :)

I'll close this issue, but feel free to link more if anything else come up

@Dosant Dosant closed this as completed Apr 7, 2025
Dosant added a commit to Dosant/kibana that referenced this issue May 8, 2025
## Summary

This PR upgrades React packages to version 18, while keeping Kibana
running in Legacy mode (`ReactDOM.render`). This is the first phase of
the React@18 upgrade; the second phase will gradually migrate Kibana to
Concurrent mode (`createRoot`) (exact plan is tbd).

Upgrade is intended to be non-breaking and behave just like React@17,
but it still requires thorough testing from all teams that own UI to
discover any potential critical UI issues. The testing was done in
elastic#203114.

Most of the breaking work was completed in previous PRs and this PR only
includes minor breaking jest tests tweaks / snapshots updates

### Backports:

- This won't be backported to 9.0
- We will discuss if we should backport this to 8.x

### Risks

Kibana’s UI functional tests coverage and significant manual testing
that was done by a lot of teams in
elastic#203114 gives us a lot of
confidence.

However, since this was a large internal change for React they still
could be issues hidden in "remote" parts of UIs, think of blank screens,
error splash screens, unresponsive pages, new errors in the console,
unpredictable UI behavior (like laggy text inputs that skip letters when
typing fast).

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Konrad Szwarc <konrad.szwarc@elastic.co>
(cherry picked from commit f7fa6dd)

# Conflicts:
#	package.json
#	x-pack/solutions/security/packages/kbn-securitysolution-exception-list-components/src/exception_item_card/conditions/entry_content/__snapshots__/entry_content.test.tsx.snap
#	x-pack/solutions/security/plugins/security_solution/public/explore/network/components/arrows/__snapshots__/index.test.tsx.snap
#	x-pack/solutions/security/plugins/session_view/public/components/process_tree_alert/__snapshots__/index.test.tsx.snap
#	yarn.lock
@Dosant
Copy link
Contributor Author

Dosant commented May 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meta React@18 Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)
Projects
None yet
Development

No branches or pull requests