I have a JSX file like this:
var Home = React.createClass({
render: function() {
return (
<Test>
...
var Test = React.createClass({
render: function() {
...
module.exports = Home;
But I cant manage that both functions load, I guess I have to add Test to module.exports, but I couldn't find a method that worked.
If you require("home.jsx")
it will automaticaly load and render your Test
component inside Home
.
It would be better to separate those components in defferent files, that will help you to manage components when your app will be too large.
test.jsx
module.exports = React.createClass({
render: function() {
return <div>Test</div>
}
})
home.jsx
var Test = require('./test.jsx');
module.exports = React.createClass({
render: function() {
return <div>
<Test>
</div>
}
})
Of course you are also able to do something like @Mukesh Sharma answer.
Thanks
Hope it helps you.
var Home = React.createClass({
render: function() {
return (
<Test>
...
var Test = React.createClass({
render: function() {
...
module.exports = {
"Home": Home,
"Test": Test
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.