Skip to content

Commit 392adc3

Browse files
committed
feat(many): remove prop-types; add support for react 19 and upgrade docs app to use it
1 parent c827833 commit 392adc3

File tree

668 files changed

+8765
-27409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

668 files changed

+8765
-27409
lines changed

.github/workflows/visual-regression.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
env:
2424
ELECTRON_EXTRA_LAUNCH_ARGS: "--remote-debugging-port=9222"
2525
with:
26-
start: npm run dev
26+
build: npm run build
27+
start: npm start
2728
working-directory: regression-test
2829
- name: Upload cypress artifact for chromatic
2930
uses: actions/upload-artifact@v4
@@ -43,7 +44,7 @@ jobs:
4344
fetch-depth: 0
4445
- uses: actions/setup-node@v4
4546
with:
46-
node-version: 22.12.0
47+
node-version: 22
4748
- name: Install dependencies
4849
run: npm ci
4950
working-directory: regression-test

cypress/component/Emotion-withStyle.cy.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
WithStyleProps,
3030
withStyle
3131
} from '@instructure/emotion/src/index'
32-
import PropTypes from 'prop-types'
3332

3433
import '../support/component'
3534
import 'cypress-real-events'
@@ -102,10 +101,6 @@ const generateStyle = function (
102101

103102
@withStyle(generateStyle, generateComponentTheme)
104103
class ThemeableComponent extends Component<Props, State> {
105-
static propTypes = {
106-
inverse: PropTypes.bool
107-
}
108-
109104
static defaultTypes = {
110105
inverse: false
111106
}

docs/contributor-docs/theming/theming-class-based.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ import generateComponentTheme from './theme'
2727

2828
@withStyle(generateStyle, generateComponentTheme)
2929
class Button extends React.Component {
30-
static propTypes = {
31-
// eslint-disable-next-line react/require-default-props
32-
makeStyles: PropTypes.func,
33-
// eslint-disable-next-line react/require-default-props
34-
styles: PropTypes.object
35-
}
36-
3730
componentDidMount() {
3831
this.props.makeStyles()
3932
}
@@ -213,13 +206,6 @@ type: code
213206
---
214207
// Button/index.js
215208
class Button extends React.Component {
216-
static propTypes = {
217-
// eslint-disable-next-line react/require-default-props
218-
makeStyles: PropTypes.func,
219-
// eslint-disable-next-line react/require-default-props
220-
styles: PropTypes.object
221-
}
222-
223209
constructor(props) {
224210
super(props)
225211

Lines changed: 67 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,105 @@
11
---
2-
title: Upgrade Guide for Version 10.0
2+
title: Upgrade Guide for Version 11
33
category: Guides
4-
order: 98
4+
order: 7
55
---
66

7-
# Upgrade Guide for Version 10
7+
# Upgrade Guide for Version 11
88

9-
## Introduction
9+
## InstUI and React
1010

11-
InstUI v10 is a major release with a new theming color system. It has been simplified and rewritten to make our design language easier to understand and more uniform.
11+
> React 16 support was dropped with InstUI 11. Please upgrade to React 18 before upgrading to InstUI v11!
1212
13-
With the new system some old designs could be more challenging or very hard to implement. This is intentional, we wanted
14-
to avoid situations when someone really changes the look and feel of their application.
15-
In these cases, make sure you talk with your designer and update the UI according to the new designs.
13+
### React 19
1614

17-
The revised designs should result in better accessibility ([WCAG 2.1](https://www.w3.org/TR/WCAG21/) compliance!), less theming code and more uniform look and feel.
15+
InstUI v11 added support for React 19. But upgrading to React 19 might cause issues because InstUI needs to access the native DOM in some cases and React introduced a breaking change here by [removing `ReactDOM.findDOMNode()`](https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-reactdom-finddomnode). If you are upgrading to React 19, you will need to add `ref`s to some of your custom components that use InstUI utilities, see [this guide](#accessing-the-dom). We suggest to check your code thoroughly for errors, especially places where you use your own components as some kind of popovers or its triggers (e.g. Menu, Popover, Tooltip, Drilldown,..).
1816

19-
## Step-by-step guide
17+
If you are using React 18 you might just see error messages like (`Error: ${elName} doesn't have "ref" property.`), but your code should work the same as with InstUI v10.
2018

21-
We recommend upgrading your application for each major version gradually, e.g. if you plan to update from 8.x to 10.x,
22-
then migrate first to the latest 9.x and then to version 10.
19+
---
2320

24-
The places where your code can break during the upgrade are related to theme overrides, color props and color utilities.
25-
Please check the [theming components](#theming-components) guide to understand the new color system.
21+
## PropTypes Support Dropped
2622

27-
If you override the theme colors, you must use the new colors provided either in the `canvas-high-contrast` or in the `canvas` theme object.
28-
The previous color system has been removed, the old color names are no longer available.
23+
With React 19, support for **PropTypes was dropped** from the core library. While it's still possible to use them with third-party libraries, InstUI has decided to no longer support them based on user feedback.
2924

30-
### `Instructure` theme is removed
25+
**Tip:** To see how the removal of `propTypes` might affect your application's business logic, you can use a Babel plugin like [babel-plugin-transform-react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) to strip them out during your build process for testing.
3126

32-
Instructure theme (`@instructure/instructure-theme`) is no longer maintained and not compatible with InstUI v10.
33-
If you were using it, you need to switch to the `canvas` or the `canvas-high-contrast` theme.
27+
---
3428

35-
### Component level color overrides
29+
## Changes to Testability
3630

37-
If you had component level overrides of colors you need to migrate using the following table:
31+
The **`@testable` decorator has been removed**. The `data-cid` props, which were previously added by this decorator in development builds, are now **always added to components**. This change was made in response to frequent requests for a consistent way to identify InstUI components for end-to-end (e2e) tests.
3832

39-
| Old | New (v10) |
40-
| ------------------ | ----------------------------- |
41-
| `colors.brand` | `colors.contrasts.blue4570` |
42-
| `colors.link` | `colors.contrasts.blue4570` |
43-
| `colors.electric` | `colors.contrasts.blue4570` |
44-
| `colors.shamrock` | `colors.contrasts.green4570` |
45-
| `colors.barney` | `colors.contrasts.blue4570` |
46-
| `colors.crimson` | `colors.contrasts.red4570` |
47-
| `colors.fire` | `colors.contrasts.orange4570` |
48-
| `colors.licorice` | `colors.contrasts.grey125125` |
49-
| `colors.oxford` | `colors.contrasts.grey100100` |
50-
| `colors.ash` | `colors.contrasts.grey4570` |
51-
| `colors.slate` | `colors.contrasts.grey4570` |
52-
| `colors.tiara` | `colors.contrasts.grey1214` |
53-
| `colors.porcelain` | `colors.contrasts.grey1111` |
54-
| `colors.white` | `colors.contrasts.white1010` |
33+
As a result of this change, the **`ALWAYS_APPEND_UI_TESTABLE_LOCATORS`** Node.js environment variable is no longer used.
5534

56-
You can use the latest [codemod](#ui-codemods) to automate this process.
35+
---
5736

58-
InstUI v9:
37+
## Removal of deprecated props/components/APIs
5938

60-
```jsx
61-
---
62-
type: code
63-
---
64-
<Heading level="h3" color="primary"
65-
themeOverride={{primaryColor: canvas.colors.brand}}>
66-
I have nice color!
67-
</Heading>
68-
```
39+
### InstUISettingsProvider
6940

70-
InstUI v10:
41+
[InstUISettingsProvider](#InstUISettingsProvider)'s `as` prop was removed, it will always render as a `<span>` (note: it will only render anything to the DOM if you provide a value to the `dir` prop.). The provided codemod will remove this prop automatically (see below).
42+
43+
### Theming engine changes
44+
45+
| Removed | What to use instead? |
46+
| :------------------------------------------------- | :---------------------------------------------------------------------------------------------------- |
47+
| `canvas.use()`, `canvasHighContrast.use()` | Wrap all your application roots in `<InstUISettingsProvider>` |
48+
| `canvasThemeLocal`, `canvasHighContrastThemeLocal` | Use `canvas` and `canvasHighContrast` respectively, they are the same objects. |
49+
| `variables` field on theme objects | Use `canvas.borders` instead of `canvas.variables.borders` (same for all other fields) |
50+
| `@instructure/theme-registry` package | This added the removed functions above. Wrap all your application roots in `<InstUISettingsProvider>` |
51+
52+
### Removal of the `deprecated`, `experimental`, `hack` decorators
53+
54+
We have removed these utilities from the `ui-react-utils` package because we are phasing out parts from the codebase that use decorators.
55+
56+
If you want to still use these we suggest to copy-paste their code from the latest v10 codebase (Note: they only work for class-based components!).
7157

72-
```jsx
73-
---
74-
type: code
7558
---
76-
<Heading level="h3" margin="small small" color="primary"
77-
themeOverride={{primaryColor: canvas.colors.contrasts.blue4570}}>
78-
some nice blue text.
79-
</Heading>
80-
```
8159

82-
Notice, that the new values use `colors.contrasts`. Please do not use `colors.primitives` for anything.
60+
## Component Changes
61+
62+
### CodeEditor
63+
64+
The **`<CodeEditor>` component** from the `ui-code-editor` package has been **removed** due to significant accessibility issues. Please use the **`<SourceCodeEditor>`** component as a replacement.
8365

84-
### Theme level color overrides
66+
### Table
8567

86-
InstUI v9 theme level properties `text`, `background`, `border` (for example `backgroundLightest` or `textDarkest`) have been removed.
87-
To upgrade these props you need to find and override component level theme variables for each component that used the replaced property.
88-
**This is heavily discouraged, upcoming designs should not necessitate theme overrides.**
68+
[Table](#Table) is now using [TableContext](#TableContext) to pass down data to its child components, the following props are no longer passed down to their children (This should only affect you if you have custom table rows or cells):
8969

90-
For example, if you had `backgroundLightest` overridden on the theme level, you need to find every component whose theme
91-
utilizes `backgroundLightest` and override them individually in each component. Some of these components are `Alert`, `Avatar`, `Billboard`, `View` and many more.
70+
| Component | prop | Substitute / Notes |
71+
| :-------- | :---------- | :------------------------------ |
72+
| `Row` | `isStacked` | is now stored in `TableContext` |
73+
| `Body` | `isStacked` | is now stored in `TableContext` |
74+
| `Body` | `hover` | is now stored in `TableContext` |
75+
| `Body` | `headers` | is now stored in `TableContext` |
9276

93-
InstUI v9:
77+
### Tag
78+
79+
The **`maxWidth` theme variable has been removed** from the `Tag` component. As a result, **`<Tag>` can no longer be truncated**. This change was made because placing a tooltip on a non-interactive element is an accessibility anti-pattern. You will need to handle truncation and tooltips via a new design if this functionality is required.
9480

95-
```jsx
9681
---
97-
type: code
82+
83+
## API Changes
84+
85+
- `ui-dom-utils`/`getComputedStyle` can now return `undefined`: In previous versions it sometimes returned an empty object which could lead to runtime exceptions when one tried to call methods of `CSSStyleDeclaration` on it.
86+
9887
---
9988

100-
<InstUISettingsProvider
101-
theme={{
102-
themeOverrides: {
103-
canvas: {
104-
colors: { backgroundLightest: 'orange' }
105-
}
106-
}
107-
}}
108-
>
109-
```
89+
## Codemods
11090

111-
InstUI v10:
91+
To ease the upgrade we provide codemods that will automate most of the changes. Pay close attention to its output, it cannot refactor complex code! The codemod scripts can be run via the following commands:
11292

113-
```jsx
93+
```sh
11494
---
11595
type: code
11696
---
117-
118-
<Alert themeOverride={{background: 'orange'}}></Alert>
119-
<Avatar themeOverride={{background: 'orange'}}></Avatar>
120-
<Billboard themeOverride={{background: 'orange'}}></Billboard>
121-
<Tabs themeOverride={{defaultBackground: 'orange', scrollFadeColor:'orange'}}></Tabs>
122-
//...and all other components that use color.backgroundLightest
97+
npm install @instructure/ui-codemods@11
98+
npx [email protected] -t node_modules/@instructure/ui-codemods/lib/instUIv11Codemods.ts <path> --usePrettier=false
12399
```
100+
101+
Options for the codemod:
102+
103+
- `filename`: if specified then emitted warnings are written to this file.
104+
- `usePrettier`: if `true` the transformed code will be run through Prettier. You can customize this through a [Prettier
105+
config file](https://prettier.io/docs/configuration.html)

docs/contributor-docs/v11-upgrade-guide.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

docs/guides/accessing-the-dom.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,23 @@ order: 5
88

99
Accessing the DOM directly in React is discouraged, because it pierces the DOM abstraction. Still there are some cases when InstUI is required to do so (for example for focus management or positioning). This happens with the [findDOMNode](#findDOMNode) utility function.
1010

11-
For custom React components this method first tries to access a `ref` property. If this does not exist, it will use React's deprecated [`findDOMNode` utility](https://reactjs.org/docs/react-dom.html#finddomnode) as a fallback. This will result in warnings about its usage on the console. (Read more about this [here](https://en.reactjs.org/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage).)
11+
For custom React components this method first tries to access a `ref` property. If this does not exist, then:
1212

13-
To get rid of this warning, please add a `ref` property to the component that returns the underlying DOM node:
13+
- For React 19 or newer it will return `undefined` because `ReactDOM.findDOMNode()` was removed. This means that **custom components without the `ref` prop will not work in React 19 or newer!**
14+
- For React 18 or older it will call `ReactDOM.findDOMNode()`
15+
16+
Places where the `ref` prop is needed for custom components (you can use any InstUI component, they have this prop already:
17+
18+
- [Tooltip](#Tooltip)'s children (if there is no `as` prop)
19+
- [Popover](#Popover)'s `renderTrigger` prop
20+
- [Menu](#Menu)'s `trigger` prop
21+
- [AiInformation](#AiInformation)'s `trigger` prop
22+
- [Position](#Position)'s child and `target` prop
23+
- [Transition](#Transition)'s child
24+
- [Dialog](#Dialog)'s `contentElement`prop
25+
- ... and possibly others, please check your console for errors!
26+
27+
To fix the issue add a `ref` property to the component that returns the underlying DOM node:
1428

1529
```javascript
1630
---
@@ -25,7 +39,6 @@ class MyComponent extends React.Component {
2539
return <div ref={this.ref}>Content</div>
2640
}
2741
}
28-
2942
```
3043

3144
```javascript
@@ -90,7 +103,7 @@ Good Usage Example with `ref`:
90103
render(<Example />)
91104
```
92105

93-
Bad Usage Example without `ref`, that will result in InstUI calling `ReactDOM.findDOMNode()` and throw warnings:
106+
Bad Usage Example without `ref`, that will result in InstUI calling `ReactDOM.findDOMNode()` and throw warnings. Also, this code will **NOT** work with React 19+:
94107

95108
- ```js
96109
class BadComponent extends React.Component {

docs/guides/module-federation.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ order: 1
88

99
InstUI supports [module federation](https://module-federation.io/) with some caveats. In a host app-guest app scenario, you have 2 choices depending on the version of InstUI you are using:
1010

11-
### (Recommended) Host and guest app are using larger version than InstUI v10.14:
11+
### InstUI v11 or newer
12+
13+
Just use themes as you would without module federation. Note that theme objects are not shared between instances, you will need to pass overrides manually to guest apps if needed.
14+
15+
### InstUI v10.14 - v10.latest:
1216

1317
- Both apps should use `canvasThemeLocal` or `canvasHighContrastThemeLocal` from the `@instructure/ui-themes` package when using themes. This means that `InstUISettingsProvider`'s theme prop cannot be left unset because it will default to `canvas`.
1418
- Apps cannot use `canvas.use()`, `canvasHighContrast.use()`, these do not exist in the local themes.

0 commit comments

Comments
 (0)