![](/img/trans.png)
[英]How can i get HTML Formated text in this popup box Like: <li> _ _ _ _</li> <br> <h1> _ _ _ _</h1>etc
[英]PropTypes check for specific children eg. <li>, <h1>, etc
比方說,我有以下簡單的組件:
const List = ({ children, ...props }) => (
<ul {...props}>
{children}
</ul>
);
對應的 propTypes 如下:
List.propTypes = {
children: PropTypes.node
};
如何使 propTypes 更具體?
這樣它就可以接受一個或多個<li>
(包含<li>
內的任何內容),但不能接受<div>
例如?
像這些例子:
<List>
<li>Singe item</li>
</List>
<List>
<li>First item</li>
<li>Second item</li>
</List>
謝謝您的幫助!
好問題,保持簡單。 也許您應該嘗試使用 Fragment。 例如
<List>
<Fragment>
<li>First item</li>
<li>Second item</li>
</Fragment>
</List>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.