Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 15, 2022

Conversation

feedm3
Copy link
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
src/utils/react-18-compat.ts Show resolved Hide resolved
src/components/Form/index.tsx Show resolved Hide resolved
src/components/PaddedContainer/index.tsx Outdated Show resolved Hide resolved
src/utils/react-18-compat.ts Outdated Show resolved Hide resolved
@dremartins dremartins merged commit 14c5e1a into ZEISS:main Nov 15, 2022
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