4
私はreact-bootstrap button docを読んで理解できないcomponentClass
小道具があります。 「このコンポーネントにカスタム要素タイプを使用できます」などの説明があります。reactbootstrapのcomponentClass propの目的は何ですか
この小道具の目的は何ですか?どんな例でも分かるでしょう。
私はreact-bootstrap button docを読んで理解できないcomponentClass
小道具があります。 「このコンポーネントにカスタム要素タイプを使用できます」などの説明があります。reactbootstrapのcomponentClass propの目的は何ですか
この小道具の目的は何ですか?どんな例でも分かるでしょう。
ここにDocがあります。基本的に、Button
コンポーネントを作成すると、デフォルトでbutton
html要素としてレンダリングされます。 「カスタムコンポーネント」内にラップさせたい場合は、たとえば<span>
のようにcomponentClass
プロパティを使用して処理することができます。
例:Button
デフォルトbutton
要素とspan
でCustomButton
としてレンダリングされる。この場合
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'));
。