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

Addon-docs: Fix React Suspense in source snippets. #19787

Closed

Conversation

zhyd1997
Copy link
Contributor

@zhyd1997 zhyd1997 commented Nov 9, 2022

Issue: #11554

What I did

add <React.Suspense> support in `source snippets.

How to test

  • Is this testable with Jest or Chromatic screenshots?
  • Does this need a new example in the kitchen sink apps?
  • Does this need an update to the documentation?

If your answer is yes to any of these, please make sure to include it in your PR.

@zhyd1997
Copy link
Contributor Author

zhyd1997 commented Nov 9, 2022

Refactored PR: #19785

@zhyd1997 zhyd1997 marked this pull request as draft November 9, 2022 10:19
@zhyd1997 zhyd1997 marked this pull request as ready for review November 9, 2022 11:00
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this @zhyd1997 !! Is there a full list of these "known symbols" somewhere & can we do all of them in this PR?

expect(renderJsx(createElement(SuspenseComponent, {}, 'I am Suspense'), {}))
.toMatchInlineSnapshot(`
<SuspenseComponent>
I am Suspense
Copy link
Member

Choose a reason for hiding this comment

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

Any ideas why the <div> is not showing up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @shilman

I submitted a refactor PR: #19785 to handle other "know symbols", but have some issues on CI, you can check it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uhh, div, sorry, it's my problem, I will add it when I come back my office.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually It works for new creat-react-app when I added them in bundled code, I will figure out why the test passed with wrong snapshot.

@zhyd1997
Copy link
Contributor Author

zhyd1997 commented Nov 10, 2022

Hi @shilman!

with the help of @JReinhold on Discord, I have fixed the CI errors on PR #19785

  • added a new react type support -- StrictMode, other types will be added later, and
  • in my opinion, the div missing is another issue...

so could we talk about the feature/bug on PR #19785 ?

Update:

why the <div> is not showing up?

I think it's related to react-element-to-jsx-string library: #18269 (comment)

Reproduce:

import React, { createElement } from 'react';
import reactElementToJSXString from 'react-element-to-jsx-string';

function SuspenseComponent(props: any) {
  return (
    <React.Suspense fallback={null}>
      <div>{props.children}</div>
    </React.Suspense>
  );
}

console.log(reactElementToJSXString(createElement(SuspenseComponent, {}, 'I am Suspense'), {}));
// -------- log ----------
<SuspenseComponent>
  I am Suspense
</SuspenseComponent>

@shilman shilman self-assigned this Nov 14, 2022
@ndelangen
Copy link
Member

@zhyd1997 Is the other PR a replacement for this one?

Can I close this PR, then?

@zhyd1997
Copy link
Contributor Author

Hi @ndelangen

The replacement: #19785

@zhyd1997 zhyd1997 closed this Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants