You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

遭遇Parsing error: Unterminated JSX contents解析错误,求协助排查(附代码)

Fixing "Parsing error: Unterminated JSX contents" in Your Code

Hey there! That error typically signals a syntax issue in your JSX—either an element that’s not properly closed, or a syntax quirk throwing off the parser. Let’s walk through the fixes step by step:

Key Issues & Solutions

  • Swap class for className: In React JSX, class is a reserved JavaScript keyword, so we use className instead to assign CSS classes. This is a mandatory JSX rule, and while it might not be the direct cause of your current error, it will prevent other bugs down the line.
  • Double-check tag closure: Even though your code looks like all tags are closed at first glance, take a quick pass to confirm every opening tag has a matching closing tag, and self-closing elements like <br/> use the correct /> syntax (yours checks out here, but it’s always worth verifying!).
  • Optimize the style attribute (optional but recommended): JSX works best with style attributes written as JavaScript objects rather than strings. This makes dynamic styling easier and aligns with React’s best practices.

Corrected Code

<div className="hero-wrap js-fullheight" style={{ backgroundImage: `url('images/bg_1.jpg')` }} data-stellar-background-ratio="0.5">
  <div className="overlay"></div>
  <div className="container">
    <div className="row no-gutters slider-text js-fullheight align-items-center justify-content-start" data-scrollax-parent="true">
      <div className="col-xl-10 ftco-animate" data-scrollax=" properties: { translateY: '70%' }">
        <h1 className="mb-4" data-scrollax="properties: { translateY: '30%', opacity: 1.6 }"> Get <br/><span>your Things Done</span></h1>
        <p className="mb-4" data-scrollax="properties: { translateY: '30%', opacity: 1.6 }">Over 10K People across Sri Lanka <br/><span> are willing to Help you</span></p>
      </div>
    </div>
  </div>
</div>

If the Error Sticks Around

If you still see the error after these tweaks, check the context where this code lives. Is it nested inside another JSX element that’s not properly closed? Sometimes the parser throws this error for issues in surrounding code, not the snippet itself. You can also try restarting your code editor or linting tool—cached state can sometimes cause false positives.

内容的提问来源于stack exchange,提问作者Akash HARISHANTH

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 09:26:09