What is the purpose of componentassass prop component in reactbootstrap

I read the file-responder-reload doc and there is componentClassprop which I cannot understand. They explain this as "You can use a custom item type for this component."

What is the purpose of this prop? Any examples would be appreciated.

+4
source share
1 answer

The dock is right here. Basically, when you create a component, Buttonit will appear as the Buttondefault html element . If you want it to be wrapped inside a "custom component", for example <span>, you can use the property componentClassto handle this for you.

Example:

  var Button = React.createClass({

    render() {
      return <h1 ref='button_node'>
      <ReactBootstrap.Button bsStyle="success">Button</ReactBootstrap.Button>
      </h1>;
    }
  });  

  var CustomButton = React.createClass({

    render() {
      return <h1 ref='button_node'>
      <ReactBootstrap.Button componentClass="span" bsStyle="danger">Custom one</ReactBootstrap.Button>
      </h1>;
    }
  });  

  ReactDOM.render(<Button/>, document.getElementById('button')); 
  ReactDOM.render(<CustomButton/>, document.getElementById('custom-button')); 

Button Button CustomButton span.

+3

Source: https://habr.com/ru/post/1648858/


All Articles