反応コンポーネントを使用するために従来のweb2py(Python)アプリケーションをアップグレードしています。 jsxファイルをjsバンドルに縮小するためにwebpackを使用しています。Webpackバンドル内の反応コンポーネントのライブラリ実行時のレンダリングで使用するためのエクスポート
ReactDOM.render(
<ComponentA arg1="hello" arg2="world" />,
document.getElementById('react-container')
);
ここで、ComponentAはバンドルに含まれており、バンドルはweb2pyビューに含まれています。問題は、ビューでComponentAにアクセスできないことです。
<script>
var ComponentA = React.createClass({
render: function() {
var p = React.createElement('p', null, 'Passed these props: ',this.props.arg1, ' and ', this.props.arg2);
var div = React.createElement('div', { className: 'my-test' }, p);
return div;
}
});
var component = React.createElement(ComponentA, {arg1:"hello", arg2:"world"})
ReactDOM.render(
component,//I would rather use <ComponentA arg1="hello" arg2="world" />,
document.getElementById('react-sample')
);
</script>
は、私がexports-loaderとに見えたが、私はまだそれが動作するように得ていない次の例では動作します。どんな助けでも大歓迎です。
幾分完全には関係していない:[expose-a-component-library-in-react](http://stackoverflow.com/questions/38121955/unable-to-expose-a-component-library-in- web-pack-and-babelと反応する)と[反応するコンポーネントが必要](http://stackoverflow.com/questions/38678439/unable-to-require-a-react-component) –