📜  反应为每个孩子添加类 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:46.428000             🧑  作者: Mango

代码示例1
const StyleInjector = ({ children }) => {
   const StyledChildren = () =>
    React.Children.map(children, child =>
      React.cloneElement(child, {
        className: `${child.props.className} ${PUT_YOUR_CLASS_HERE}`
      })
    );

  return ;
};