3.0 KiB
3.0 KiB
id | title | challengeType | isRequired | videoUrl | localeTitle |
---|---|---|---|---|---|
5a24bbe0dba28a8d3cbd4c5d | Create a Complex JSX Element | 6 | false | 创建一个复杂的JSX元素 |
Description
<DIV>JSX无效:
<p>第一段</ p>
<p>第二段</ p>
<p>第3段</ p>
</ DIV>
<p>第一段</ p>
<p>第二段</ p>
<p>第3段</ p>
Instructions
JSX
,它呈现一个按顺序包含以下元素的div
:一个h1
,一个p
和一个包含三个li
项的无序列表。您可以在每个元素中包含所需的任何文本。 注意:渲染多个这样的元素时,可以将它们全部括在括号中,但并不是严格要求的。另请注意,此挑战使用div
标记将所有子元素包装在单个父元素中。如果删除div
,JSX将不再转换。请记住这一点,因为当您在React组件中返回JSX元素时它也将适用。 Tests
tests:
- text: 常量<code>JSX</code>应该返回一个<code>div</code>元素。
testString: 'assert(JSX.type === "div", "The constant <code>JSX</code> should return a <code>div</code> element.");'
- text: <code>div</code>应该包含一个<code>p</code>标签作为第二个元素。
testString: 'assert(JSX.props.children[1].type === "p", "The <code>div</code> should contain a <code>p</code> tag as the second element.");'
- text: <code>div</code>应包含<code>ul</code>标记作为第三个元素。
testString: 'assert(JSX.props.children[2].type === "ul", "The <code>div</code> should contain a <code>ul</code> tag as the third element.");'
- text: <code>div</code>应包含一个<code>h1</code>标记作为第一个元素。
testString: 'assert(JSX.props.children[0].type === "h1", "The <code>div</code> should contain an <code>h1</code> tag as the first element.");'
- text: <code>ul</code>应该包含三个<code>li</code>元素。
testString: 'assert(JSX.props.children[2].props.children.length === 3, "The <code>ul</code> should contain three <code>li</code> elements.");'
Challenge Seed
// write your code here
After Test
console.info('after the test');
Solution
// solution required