Skip to content

Conversation

@Ciorolla
Copy link
Contributor

@Ciorolla Ciorolla commented Apr 19, 2025

This pull request includes several updates to dependencies, refactors for improved type safety, and code modernization. Key changes include upgrading React and related libraries, replacing react-copy-to-clipboard with a custom CopyToClipboard component, and updating ReactDOM usage to align with React 18+ standards.

Dependency Updates:

  • Upgraded react and react-dom to version 19.1.0 and updated @types/react to match the new version. Removed react-copy-to-clipboard and its type definitions, replacing it with the copy-to-clipboard library. [1] [2]
  • Added copy-to-clipboard as a new dependency in package.json.

Type Safety Improvements:

  • Updated useRef types across multiple components to explicitly allow null where necessary, improving type safety and preventing potential runtime errors. Examples include workerRef in PythonConverterService.tsx, zoneRef in ZoneManagerPanel.tsx, and wrapperElementRef in SceneEditor.tsx. [1] [2] [3]
  • Refactored SidebarTreeItem to handle ref cleanup properly by deleting entries from objectRefs when the ref becomes null.

Code Modernization:

  • Replaced the deprecated ReactDOM.render with createRoot from react-dom/client to align with React 18+ standards.
  • Refactored SimulationCardGrid components to use functional props for header and footer, simplifying their usage and improving code readability. [1] [2] [3]

Component Refactoring:

  • Introduced a custom CopyToClipboard component to replace the removed react-copy-to-clipboard library. This component is implemented as a reusable, type-safe React class component. [1] [2]

Minor Adjustments:

  • Added RefObject to imports in SceneEditor.tsx to support updated type annotations.

dependabot bot and others added 2 commits April 18, 2025 10:42
Bumps [react](https://github.com/facebook/react/tree/HEAD/packages/react) and [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react). These dependencies needed to be updated together.

Updates `react` from 18.3.1 to 19.0.0
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v19.0.0/packages/react)

Updates `@types/react` from 18.3.14 to 19.0.7
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: react
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…ackage was removed due to incompatibility with React 19.1.0, and a custom component was added instead.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR bumps React and its types and refactors various components to align with updated APIs and stricter type annotations.

  • Replace legacy ReactDOM.render with the new createRoot API in src/index.tsx.
  • Refactor SimulationCardGrid header and footer props to use JSX syntax and update related type annotations.
  • Adjust ref and worker type annotations for improved type safety in several components.

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/index.tsx Updated React root rendering using the createRoot API.
src/WrapperApp/components/Simulation/SimulationCardGrid.tsx Refactored header/footer rendering to use explicit JSX structure and updated type signatures.
src/WrapperApp/components/Results/Results3D.tsx Changed Clipboard import to a local custom implementation.
src/WrapperApp/components/CopyToCliboard/CopyToCliboard.jsx Added a new custom CopyToClipboard component.
src/ThreeEditor/components/ZoneManagerPanel/ZoneManagerPanel.tsx Improved useRef type safety by allowing null.
src/ThreeEditor/components/Sidebar/SidebarTree/SidebarTreeItem.tsx Updated ref callback to correctly manage objectRefs with addition and deletion.
src/ThreeEditor/components/Editor/SceneEditor.tsx Adjusted ref types and cast to HTMLElement for keyboard controls.
src/PythonConverter/PythonConverterService.tsx Updated workerRef type to account for null values.
src/JsRoot/hook/useJsRootCanvas.tsx Ensured the container ref is cast to the expected HTMLDivElement type.
Files not reviewed (1)
  • package.json: Language not supported

Copy link
Contributor

@grzanka grzanka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but take a look on some typo reported by copilot

@grzanka
Copy link
Contributor

grzanka commented Apr 22, 2025

@Ciorolla solve conflicts introduced by merging #2032

@grzanka grzanka requested a review from Copilot April 22, 2025 17:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the codebase by upgrading React dependencies, refactoring components for improved type safety, and replacing deprecated libraries with custom implementations.

  • Upgrades React and ReactDOM to version 19.1.0 using createRoot for rendering
  • Replaces react-copy-to-clipboard with a custom CopyToClipboard component and updates related imports
  • Enhances type safety with explicit ref types and ref cleanup in several components

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/index.tsx Replaces ReactDOM.render with createRoot and adds a conditional container check
src/WrapperApp/components/Simulation/SimulationCardGrid.tsx Refactors header and footer prop usage for simulation grid components
src/WrapperApp/components/Results/Results3D.tsx Updates the import to use the new CopyToClipboard component
src/WrapperApp/components/CopyToClipboard/CopyToClipboard.jsx Introduces a custom, type-safe CopyToClipboard component
src/ThreeEditor/components/ZoneManagerPanel/ZoneManagerPanel.tsx Improves type safety for zoneRef by explicitly allowing null values
src/ThreeEditor/components/Sidebar/SidebarTree/SidebarTreeItem.tsx Implements proper ref cleanup in the SidebarTreeItem component
src/ThreeEditor/components/Editor/SceneEditor.tsx Updates ref types and casts for improved type safety in SceneEditor
src/PythonConverter/PythonConverterService.tsx Allows null values for workerRef to improve type safety
src/JsRoot/hook/useJsRootCanvas.tsx Casts containerEl to the appropriate RefObject for use with ResizeObserver
Files not reviewed (1)
  • package.json: Language not supported

@grzanka grzanka added this pull request to the merge queue Apr 22, 2025
Merged via the queue into master with commit 0f7791c Apr 22, 2025
8 checks passed
@grzanka grzanka deleted the bump-react-and-types-1959 branch April 22, 2025 17:58
lkwinta pushed a commit that referenced this pull request Apr 23, 2025
* build(deps): bump react and @types/react

Bumps [react](https://github.com/facebook/react/tree/HEAD/packages/react) and [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react). These dependencies needed to be updated together.

Updates `react` from 18.3.1 to 19.0.0
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v19.0.0/packages/react)

Updates `@types/react` from 18.3.14 to 19.0.7
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: react
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* React was bumped from 18.3.1 to 19.1.0. The react-copy-to-clipboard package was removed due to incompatibility with React 19.1.0, and a custom component was added instead.

* TypoFixed

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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