Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
218 views
in Technique[技术] by (71.8m points)

reactjs - "Gatsby build" orders jsx improperly, but gatsby develop doesn't

An <a> tag with a <div> inside is generated with the entire <a> tag (including closing tag) before the <div> that is supposed to be inside it. When running "gatsby develop" this never happens and before today "gatsby build" didn't have this issue either.

For reference:

<a href={props.link} target="_blank" rel="noreferrer" className={"tile is-child" + (isolated ? " is-3" : "")}>
            <div className="card m-3 is-clickable is-link">
                <div className="card-image">
                    <InfoOverlay name={props.status} color={props.statusColor ? props.statusColor : "light"} overlayLink={props.overlayLink} />
                    <figure className="image is-2by1">
                        <img src={props.image} alt={props.name + " Image"} style={{ objectFit: "cover" }} />
                    </figure>
                </div>
                <div className="card-content">
                    <div className="media">
                        <Icon props={props} />
                        <div className="media-content">
                            <div className={"title" + (props.tSize !== "undefined" ? " is-" + props.tSize : " is-3")} style={{ paddingTop: sizeDict[tSize][0], paddingBottom: sizeDict[tSize][1] }}>{props.name}</div>
                        </div>
                    </div>
                </div>
            </div>
</a>

I can't seem to find this issue anywhere else, but that could be the case of me not knowing where to look (this is my first gatsby project and my first relatively complex react project). If this is too little information, let me know and I can send more. Any help would be appreciated!

question from:https://stackoverflow.com/questions/65622973/gatsby-build-orders-jsx-improperly-but-gatsby-develop-doesnt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

All of the contents of <InfoOverlay /> (which I didn't include the code to) are wrapped in a separate <a> tag, causing the renderer to work improperly. This appears to be neither Gatsby nor React breaking, but the browser. Remedy is to remove the link and make it visually appear nested, rather than actually nest them.

This post covers the core of the problem: https://stackoverflow.com/a/9883044/9214204


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...