2016-11-10 5 views
0

おはようございます。私は、既存のサイトにいくつかのコンポーネントを追加するためにVanilla React(NodeJSを使用せずに)を使用しようとしています。バニラReactJS JSXファイルのサブコンポーネントを含む

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react-dom.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script> 
<script type="text/babel" src="./js/React/src/Contact_Form.jsx"></script> 

以前はNodeJSを使用していましたが、以前は例を使用していました。私の.jsxファイル内のvar Button = require("./button");は、追加のサブコンポーネントを含めることができます。

これを達成するためのバニラとのやり取りはありますか?例えば

のindex.html - > form.jsx - >(input.jsx、select.jsx、button.jsx)ちょうどあなたがそれらを置くことができるように/関数オブジェクトです

答えて

0

コンポーネントいくつかの共有名前空間。

var Button = window.ReactComponents 
    ? window.ReactComponents.Button 
    : <span /> 

var CoolButton = props => <Button style={{ color: 'blue' }} /> 
:他のいくつかのファイルに続いて

window.ReactComponents = window.ReactComponents || {} 
window.ReactComponents.Button = props => <button /> 

関連する問題