Passing in class names to react components

前端 未结 9 788
说谎
说谎 2020-12-23 02:35

I am trying to pass in a classname to a react component to change it\'s style and cannot seem to get working:

class Pill extends React.Component {

  render(         


        
9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-23 03:12

    Just for the reference, for stateless components:

    // ParentComponent.js
    import React from 'react';
    import { ChildComponent } from '../child/ChildComponent';
    
    export const ParentComponent = () =>
      
    ...
    // ChildComponent.js import React from 'react'; export const ChildComponent = ({ className, children }) =>
    {children}

    Will render:

    ...

提交回复
热议问题