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

Chore: Better typings in @grafana/ui needed for react 18 #64828

Merged
merged 3 commits into from
Mar 16, 2023

Conversation

ashharrison90
Copy link
Contributor

What is this feature?

Why do we need this feature?

  • so we can move to react 18!

Who is this feature for?

  • grafana devs

Which issue(s) does this PR fix?:

Fixes #

Special notes for your reviewer:

@ashharrison90 ashharrison90 added type/chore no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Mar 15, 2023
@ashharrison90 ashharrison90 added this to the 9.5.0 milestone Mar 15, 2023
@ashharrison90 ashharrison90 requested a review from a team as a code owner March 15, 2023 15:52
@ashharrison90 ashharrison90 self-assigned this Mar 15, 2023
@ashharrison90 ashharrison90 requested review from a team as code owners March 15, 2023 15:52
@ashharrison90 ashharrison90 requested review from mckn, tskarhed and JoaoSilvaGrafana and removed request for a team March 15, 2023 15:52
export const ControlledCollapse: FunctionComponent<Props> = ({ isOpen, onToggle, ...otherProps }) => {
export const ControlledCollapse = ({ isOpen, onToggle, ...otherProps }: React.PropsWithChildren<Props>) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, we could just type children: React.ReactNode inProps. At the risk of bikeshedding this, might be worth checking with broader group for what pattern we want to prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, think it's worth discussing in a frontend weekly. don't think it needs to hold out this specific PR since we already have both throughout the codebase (😅).

i would propose using React.PropsWithChildren more tbh. it comes from react, so if they ever change the children type (extremely unlikely i know) it would be a no-op. and it removes any chance of an incorrect type being set (what was it again... was it React.ReactNode, React.ReactElement or JSX.Element? 🤔)

Copy link
Contributor

Choose a reason for hiding this comment

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

it's just React.ReactNode. always React.ReactNode 😅

I think.

@@ -1,5 +1,5 @@
import { css, cx } from '@emotion/css';
import React, { FunctionComponent, useState } from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

I knew about React.FC 🤣

@@ -1,2 +0,0 @@
export type Renderable = React.ComponentType | JSX.Element;
Copy link
Contributor

Choose a reason for hiding this comment

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

👋🏻

@github-actions
Copy link
Contributor

github-actions bot commented Mar 15, 2023

⚠️   Possible breaking changes

(Open the links below in a new tab to go to the correct steps)

grafana-ui has possible breaking changes (more info)

Console output
Read our guideline

@grafanabot grafanabot added the levitate breaking change A label indicating a breaking change and assigned by Levitate. label Mar 15, 2023
Copy link
Contributor

@leventebalogh leventebalogh left a comment

Choose a reason for hiding this comment

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

LGTM 👍

(Levitate is complaining about the removed types RenderFunction and Renderable, but I couldn't find any plugins depending on it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend levitate breaking change A label indicating a breaking change and assigned by Levitate. no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes type/chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants