React is doing strange things with the <p>
tag. Using the same markup structure, with a <p>
tag vs a <div>
tag produces very different results. For example,
var withP = (
<p>
withP
<div />
</p>
);
var withDiv = (
<div>
withDiv
<div />
</div>
);
Here is what the generated markup looks like in chrome:
<p>
differently than <div>
?Most elements that are used in the body of documents and applications are categorized as flow content. That includes p elements, which can only be used where flow content is expected. Therefore, div elements can contain p elements.
React renders HTML to the web page by using a function called render(). The purpose of the function is to display the specified HTML code inside the specified HTML element. In the render() method, we can read props and state and return our JSX code to the root component of our app.
Render Rich Text In your new React application, open slices/Text/index. js. This is the React component for your Text Slices. Your text is rendered by the <PrismicRichText> component.
<p>
can not have nested block elements. Chrome (not React) is transforming the markup to make it valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With