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: replace the deprecated react type definition #3382

Merged
merged 2 commits into from
May 2, 2022

Conversation

iChenLei
Copy link
Member

@iChenLei iChenLei commented Apr 30, 2022

Alternative PR for #2741

Code change checklist

  • Added/updated unit tests
  • Updated /docs. For new functionality, at least API.md should be updated
  • Verified that there is no significant performance drop (npm run perf)

PR Backgroud

When I try to solve this problem #2721 , I noticed that mobx-react(and lite) source code use
deprecated react type definition, Such as RefForwardingComponent React.Props
and StatelessComponent , so I created a PR to replace these with official recommended type def.

@types/react source code

RefForwardingComponent

  /**
   * @deprecated Use ForwardRefRenderFunction. forwardRef doesn't accept a
   *             "real" component.
   */
  interface RefForwardingComponent <T, P = {}> extends ForwardRefRenderFunction<T, P> {}

React.Props

  /**
   * @deprecated. This was used to allow clients to pass `ref` and `key`
   * to `createElement`, which is no longer necessary due to intersection
   * types. If you need to declare a props object before passing it to
   * `createElement` or a factory, use `ClassAttributes<T>`:
   *
   * ```ts
   * var b: Button | null;
   * var props: ButtonProps & ClassAttributes<Button> = {
   *     ref: b => button = b, // ok!
   *     label: "I'm a Button"
   * };
   * ```
   */
  interface Props<T> {
      children?: ReactNode;
      key?: Key;
      ref?: LegacyRef<T>;
  }

@changeset-bot
Copy link

changeset-bot bot commented Apr 30, 2022

🦋 Changeset detected

Latest commit: 9b046b4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
mobx-react Minor
mobx-react-lite Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mweststrate
Copy link
Member

Thanks for this! Would you mind marking it as minor? Beyond that looking good to me :)

@mweststrate mweststrate merged commit 4c5e75c into mobxjs:main May 2, 2022
@github-actions github-actions bot mentioned this pull request May 2, 2022
@iChenLei iChenLei deleted the react-types branch May 3, 2022 00:06
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.

2 participants