Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Theme: Children interface is now ReactNode, allows guard() and render() to accept JSX #971

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

Merged
sserrata merged 4 commits into PaloAltoNetworks:main from robbieaverill:children-reactnode
Sep 24, 2024

Conversation

@robbieaverill
Copy link
Contributor

@robbieaverill robbieaverill commented Sep 18, 2024
edited
Loading

Description

This fixes a type incompatibility in theme components where using guard() and returning a React or DOM element would not pass type checking. The Children interface now extends ReactNode for backwards compatibility and is marked as deprecated. Use ReactNode directly in future.

(削除) Duplicated markdown utility functions in the theme are now deprecated in favour of their equivalents in the plugin package. (削除ここまで) Edit: plugin methods remain the same, they look similar but serve a slightly different purpose.

Motivation and Context

Refer to theme: ParamsItem/index.tsx:

const renderDeprecated = guard(deprecated, () => (
 <span className="openapi-schema__deprecated">deprecated</span>
));

The return value of the callback in this example was invalid, as a JSX.Element is not a string, etc. I've replaced the Children type with ReactNode, which supports React elements/JSX.Element, as well as all the other values that were there (string, undefined, number, iterable variants of it, etc).

How Has This Been Tested?

Type checked locally.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Deprecation of existing APIs (requires minor release)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

...ated in favour of plugin methods
This fixes a type incompatibility where using `guard()` and returning
a React or DOM element would not pass type checking. The Children
interface now extends ReactNode for backwards compatibility and is
marked as depreacated. Use ReactNode directly in future.
Duplicated markdown utility functions in the theme are now deprecated
in favour of their equivalents in the plugin package.
Copy link

github-actions bot commented Sep 18, 2024
edited
Loading

Visit the preview URL for this PR (updated for commit 2fcfe32):

https://docusaurus-openapi-36b86--pr971-vfe03kyz.web.app

(expires 2024年10月24日 13:05:31 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

Copy link
Member

sserrata commented Sep 23, 2024
edited
Loading

Hi @robbieaverill, some descriptions don't appear to be rendering in the preview:

Screenshot 2024年09月23日 at 11 17 16 AM
robbieaverill reacted with eyes emoji

.join("");
}
return children ?? "";
return `${children ?? ""}`;
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be what results in description not rendering

robbieaverill reacted with thumbs up emoji
Copy link
Contributor Author

@robbieaverill robbieaverill Sep 23, 2024

Choose a reason for hiding this comment

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

I did some playing around. The plugin's render() method is used to create HTML strings, e.g. <p>foo</p> that are used to create the MDX files, so it doesn't actually support rendering JSX or React elements directly.

The theme does, as in my example of using guard() in a React template context.

I've pushed a new commit which removes all of the changes to the plugin and most of the deprecations in the theme, and changes the theme's guard() and render() methods to handle ReactNode. How do you feel about that?

image

sserrata reacted with hooray emoji
@robbieaverill robbieaverill changed the title (削除) Children interface is now ReactNode, theme utility methods are deprecated in favour of plugin methods (削除ここまで) (追記) Theme: Children interface is now ReactNode, allows guard() and render() to accept JSX (追記ここまで) Sep 23, 2024
@sserrata sserrata merged commit 296475b into PaloAltoNetworks:main Sep 24, 2024
15 checks passed
@robbieaverill robbieaverill deleted the children-reactnode branch September 24, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sserrata sserrata sserrata left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /