Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 277095f

Browse files
committed
chore: update to react 18
Bumping to React 18 required only a few small updates to new/updated React APIs (instead of `react-dom.render()`, it is now `react-dom.createRoot().render()`. However, their updates to the rendering stack exposed a small number of long-term race conditions in the kui code base. Thus, this PR had to clean those up. BREAKING CHANGE: `at-kui-shell/react` will now pull in react v18. BREAKING CHANGE: we now pre-allocate execUUID on when the block is first mounted (these are known as Active blocks, because they have an active input). Previously, we relied on kui core/repl/exec to allocate upon run. This leads to a race condition, where command handlers expect to be able to communicate with the views based on an execUUID... but the views may not be mounted before the command handlers start... An example of this was the PTY. pty/client in plugin-bash-like sends pty streaming output ... the Output component (in plugin-client-common) is supposed to be the receiver, but it only listens after it is mounted). With this PR, we pre-allocate the execUUID, and mount the Output block even on Active blocks.
1 parent 2146a51 commit 277095f

File tree

37 files changed

+382
-243
lines changed

37 files changed

+382
-243
lines changed

package-lock.json

Lines changed: 63 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191
"@types/needle": "2.5.3",
9292
"@types/node": "18.11.9",
9393
"@types/pluralize": "0.0.29",
94-
"@types/react": "17.0.43",
95-
"@types/react-dom": "17.0.14",
94+
"@types/react": "18.0.25",
95+
"@types/react-dom": "18.0.9",
9696
"@types/resize-observer-browser": "0.1.7",
9797
"@types/shelljs": "0.8.11",
9898
"@types/tmp": "0.2.3",
@@ -123,8 +123,6 @@
123123
"nan": "github:jkleinsc/nan#6a2f95a6a2209d8aa7542fb18099fd808a802059",
124124
"prettier": "2.8.0",
125125
"properties-parser": "0.3.1",
126-
"react": "17.0.2",
127-
"react-dom": "17.0.2",
128126
"tmp": "0.2.1",
129127
"typedoc": "0.23.21",
130128
"typedoc-plugin-markdown": "3.13.6",

packages/core/src/repl/exec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,12 +612,13 @@ export const exec = (commandUntrimmed: string, execOptions = emptyExecOptions())
612612
* @param execUUID for command re-execution
613613
*
614614
*/
615-
export const doEval = (_tab: Tab, block: Block, command: string, execUUID?: string) => {
615+
export const doEval = (_tab: Tab, block: Block, command: string, execUUID?: string, type?: ExecType) => {
616616
const tab = splitFor(_tab)
617617
const defaultExecOptions = new DefaultExecOptionsForTab(tab, block, execUUID)
618-
const execOptions: ExecOptions = !execUUID
619-
? defaultExecOptions
620-
: Object.assign(defaultExecOptions, { type: ExecType.Rerun })
618+
const execOptions: ExecOptions =
619+
execUUID === undefined && type === undefined
620+
? defaultExecOptions
621+
: Object.assign(defaultExecOptions, { execUUID, type: type === undefined ? ExecType.Rerun : type })
621622

622623
return exec(command, execOptions)
623624
}

packages/react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"url": "git+https://github.com/IBM/kui.git"
1717
},
1818
"dependencies": {
19-
"react": "17.0.2",
20-
"react-dom": "17.0.2"
19+
"react": "18.2.0",
20+
"react-dom": "18.2.0"
2121
},
2222
"publishConfig": {
2323
"access": "public"

packages/react/src/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ declare let __webpack_nonce__: string
2121
__webpack_nonce__ = _kuiNonce
2222

2323
import React from 'react'
24-
import { render as ReactDomRender } from 'react-dom'
24+
import { createRoot } from 'react-dom/client'
2525

2626
import Client from '@kui-shell/client'
2727

@@ -39,16 +39,17 @@ function renderMain(
3939
) {
4040
// re: noBootstrap; since we do the bootstrapping here, we don't
4141
// need the Client to do anything more
42-
ReactDomRender(
42+
const root = createRoot(container)
43+
44+
root.render(
4345
<Client
4446
noBootstrap
4547
isPopup={isPopup}
4648
commandLine={commandLine}
4749
title={title}
4850
initialTabTitle={initialTabTitle}
4951
quietExecCommand={quietExecCommand}
50-
/>,
51-
container
52+
/>
5253
)
5354
}
5455

plugins/plugin-client-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"anser": "2.1.1",
3131
"ansi-regex": "6.0.1",
3232
"html-entities": "2.3.3",
33-
"madwizard": ">=1.9.1",
33+
"madwizard": "^2.0.4",
3434
"monaco-editor": "0.34.1",
3535
"monaco-editor-webpack-plugin": "7.0.1",
3636
"react-markdown": "8.0.3",

0 commit comments

Comments
 (0)