microsoft / accessibility-insights-web

Accessibility Insights for Web
https://accessibilityinsights.io
MIT License
833 stars 150 forks source link

feat(react 18): upgrade to react 18. #7336

Closed v-rakeshsh closed 3 months ago

v-rakeshsh commented 4 months ago

Details

This feature updates below packages.

  1. react from v16 to v18.
  2. react-dom from v16 to v18.
  3. @types-react from v16 to v18.
  4. @types-react-dom from v16 to v18.
  5. @testing-library/react from v12 to v15.
  6. @fluentui/react from v8.x.x to v8.118.1.
  7. Removed react-helmet and added react-helmet-async.

1. Notable changes for react, react-dom:

Motivation: React 18 introduces a new root API which provides better ergonomics for managing roots. The new root API also enables the new concurrent renderer, which allows you to opt-into concurrent features.

In V16, we had below to render the component: import { render } from 'react-dom'; const container = document.getElementById('app'); render(, container);

2. Notable changes for @types-react and @types-react-dom:

Motivation: The new types are safer and catch issues that used to be ignored by the type checker. The most notable change is that the children prop now needs to be listed explicitly when defining props

Approach for type changes: So this Type changes are added using automation script https://github.com/eps1lon/types-react-codemod. This automation script is suggested in react18 migration document.

3. Notable changes for @testing-library/react:

4. Notable changes for @fluentui/react from v8.x.x to v8.118.1

5. Notable changes for react-helmet-async:

For example: export const GuidanceTitle = NamedFC<GuidanceTitleProps>('GuidanceTitle', ({ name }) => { const titleValue =Guidance for ${name} - ${productName}`; return ( <>

{titleValue}
        <h1>{name}</h1>
    </>
);

});`

6. Along with above

Context

This PR includes all changes required for migration of AI web from react16 to react18. It includes test cases fixes. It includes lint issues fixes.

Pull request checklist