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

feat: make some component types compatible with react 18#383

Merged
dremartins merged 3 commits intoZEISS:mainfrom
feedm3:fix-react-18-compat
Nov 15, 2022
Merged

feat: make some component types compatible with react 18#383
dremartins merged 3 commits intoZEISS:mainfrom
feedm3:fix-react-18-compat

Conversation

@feedm3
Copy link
Copy Markdown
Contributor

@feedm3 feedm3 commented Nov 15, 2022

Types of Changes

Prerequisites

Please make sure you can check the following two boxes:

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project

Contribution Type

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue, please reference the issue id)
  • New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Description

We are using precise-ui in a react 18 project. Since react 18, React.FC doesn't have the children prop anymore. Therefore, we get a Typescript error as soon as we add a child to a component that uses React.FC.

In order to keep the change minimal, I did 2 things:

  • Create a interface ReactComponentDefaultProps that can be used to extend property types for React.Component.
  • Created a ReactFC interface, that can be used as a drop-in replacement for React.FC

I didn't replace all React.FC components with ReactFC, but only the ones we need right now to keep the change minimal.

shirk33y
shirk33y previously approved these changes Nov 15, 2022
Comment thread src/utils/react-18-compat.ts
Comment thread src/components/Form/index.tsx
Comment thread src/components/PaddedContainer/index.tsx Outdated
Comment thread src/utils/react-18-compat.ts Outdated
@dremartins dremartins merged commit 14c5e1a into ZEISS:main Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants