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

Use "React.Fragment" to render flushed components without "span" #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Use "React.Fragment" to render flushed components without "span" #53

wants to merge 1 commit into from

Conversation

kettanaito
Copy link

@kettanaito kettanaito commented Feb 5, 2018

Changelog

  • createApiWithCss now returns Js, Styles and Css React components using React.Fragment to render their children without a wrapping <span>
  • createApiWithCss snapshot changed according to the changes in the source file

Benefits

  • No redundant span which shouldn't wrap <link> or <script> elements
  • Doesn't affect the rest of the code, shouldn't break anything on the end-usage point as well
  • Ready for React v16+

Consequences

  • Needs to be published under major version due to the dependency from React v16+

Side notes

I've thought about this change and introduced a small pull request to cover it. I am not very familiar with Jest and its snapshots system, so you better check if I changed the snapshots correctly.

By the way, not a very good idea to include whitespaces as a part of a snapshot. Some IDE remove trailing whitespaces automatically, which causes snapshots to fail. You may want to consider removing whitespaces.

@faceyspacey
Copy link
Owner

faceyspacey commented Feb 6, 2018

Thanks for this. I'm hesitant to merge it just yet. Are you using it successfully? It may make more sense along side a larger release in the future.

Regarding the white space, I'm pretty sure that's Jest's doing, as I never edit the files directly. Perhaps prettier or eslint formatting.

@kettanaito
Copy link
Author

@faceyspacey Thanks for the reply.
Reasonable worrying. I will give this change a try in my project and post here how it went, any possible obstacles this change brings. Sounds fair?

@faceyspacey
Copy link
Owner

cool!

@serhii-ohorodnyk
Copy link

Hi @faceyspacey , is there a plan to merge this PR? I'm very much interested in this change.
I'm using react component instead of string/string-literal in my SSR solution and having style links wrapped into 'span' breaking my html (span is not allowed as child tag of header).
My Html component for SSR is very similar to this one https://github.com/leebenson/reactql/blob/master/src/views/ssr.tsx#L27, if you are interested in example.

For now I forked your repo and made "span -> React.Fragment" myself (published repo is here https://www.npmjs.com/package/webpack-flush-chunks-with-fragment). So far it works for me!

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