は、しかし、それはnullを返します:Reactコンポーネントにes6インポートエイリアス構文を使用できますか?私は、次のような何かをしようとしている
import { Button as styledButton } from 'component-library'
はその後としてそれをレンダリングしようとする:理由がある
import React, { PropTypes } from "react";
import cx from 'classNames';
import { Button as styledButton } from 'component-library';
export default class Button extends React.Component {
constructor(props){
super(props)
}
render() {
return (
<styledButton {...this.props}></styledButton>
)
}
}
、私はButton
コンポーネントをインポートする必要があります同じ名前のラッパーコンポーネントをエクスポートしますが、インポートされたコンポーネントから機能を維持することもできます。私がそれをimport { Button } from component library
に残しておけば、もちろん、私は複数の宣言エラーが発生します。
アイデア?
を? – Ved
Reactコンポーネントは大文字で始まります: 'StyledButton'ではなく' StyledButton'です。 – topheman
@Ved私は反応スタイルガイドを使ってすべてのコンポーネントを表示し、コンポーネントライブラリ内のすべてのコンポーネントをラップする必要があります。クラスボタン名を変更すると、 'show code'はプレイグラウンド内のすべてのコンポーネントに対して異なる名前になります。 –