-
Notifications
You must be signed in to change notification settings - Fork 176
/
S6748.html
23 lines (20 loc) · 999 Bytes
/
S6748.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<h2>Why is this an issue?</h2>
<p>When using JSX the component children should be passed between opening and closing tags. Passing children in a <code>children</code> prop may work
sometimes, but will lead to errors if children are passed both as nested components and <code>children</code> prop at the same time.</p>
<p>When not using JSX, the children should be passed to <code>createElement()</code> method as extra arguments after the <code>props</code>
object.</p>
<pre data-diff-id="1" data-diff-type="noncompliant">
<div children='Children' />
<Foo children={<Bar />} />
React.createElement("div", { children: 'Children' })
</pre>
<pre data-diff-id="1" data-diff-type="compliant">
<div>Children</div>
<Foo><Bar /></Foo>
React.createElement("div", {}, 'Children');
</pre>
<h2>Resources</h2>
<h3>Documentation</h3>
<ul>
<li> <a href="https://react.dev/learn/passing-props-to-a-component">React - Passing Props to a Component</a> </li>
</ul>