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

Weird jsx syntax bug / doesn't crash but renders page partially #9972

Closed
Britnell opened this issue Feb 4, 2024 · 2 comments
Closed

Weird jsx syntax bug / doesn't crash but renders page partially #9972

Britnell opened this issue Feb 4, 2024 · 2 comments
Labels
needs triage Issue needs to be triaged

Comments

@Britnell
Copy link

Britnell commented Feb 4, 2024

Astro Info

Hey, i just had this weird bug where my root page component stopped working.
no changes to code, or packages, the page suddenly only rendered the footer.
Here the code : 

<>
  {
    typeof blok?.global === "object" ? (
      <Header blok={blok.global} slug={blok.slug} />
    ) : (
      <header>No global data selected</header>
    )
  }
  
  <main>    ...    </main>
  {
    typeof blok?.global === "object" ? (
      <Footer blok={blok.global} />
    ) : (
      <footer>No global data selected</footer>
    )
  }
</>

not the greatest code, I admit, but it always worked.
then today after other changes (which i reverted) this would ONLY render the footer, but no errors nothing.

I finally fixed it by just simplifying the logic :


<>
  {blok?.global && <Header blok={blok.global} slug={blok.slug} />}
  <main > ...   </main>
  {blok?.global && <Footer blok={blok.global} />}
</>

please tell me if there is something wrong with the first code, but i thought it should have at least worked.
instead it didnt fail but only rendered the footer ...
i checked the html, its not like a closing tag was missing and it skipped parts,

and were just empty ...
is there anything special about astro jsx syntax i should know?
is there somethign like verbose mode to get output from the renderer?

  • blok is coming from storyblok

package.json :

  ...
  "dependencies": {
    "@astrojs/check": "^0.3.3",
    "@astrojs/node": "^7.0.2",
    "@astrojs/tailwind": "^5.0.3",
    "@builder.io/qwik": "^1.3.1",
    "@qwikdev/astro": "^0.3.1",
    "@storyblok/astro": "^3.0.1",
    "@storyblok/js": "^3.0.0",
    "astro": "^4.0.6",
    "tailwindcss": "^3.3.6",
    "typescript": "^5.3.3"
  },

PS thanks, shoutout to astro team killing it, this is my new gospel so please tell me if I'm getting somethign wrong



### If this issue only occurs in one browser, which browser is a problem?

_No response_

### Describe the Bug

only partially renders the page, skipping the <header> and <main>, and rendering only the last <footer>

### What's the expected result?

normal fully rendered page

### Link to Minimal Reproducible Example

can't do this today, will setup asap

### Participation

- [ ] I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 4, 2024
@MoustaphaDev
Copy link
Member

Thanks for taking the time to report this!
I can see that it's the same issue issue reported in withastro/compiler#955. We're already tracking the problem there, so I'm going to close this as a duplicate.

@MoustaphaDev MoustaphaDev closed this as not planned Won't fix, can't repro, duplicate, stale Feb 5, 2024
@Britnell
Copy link
Author

Britnell commented Feb 5, 2024

ah sorry i didnt see that. ok glad i'm not going insane haha

thanks team 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants