Reputation: 786
in one js file I have a component :
import React from 'react';
export default class ImageGrid extends React.Component {
render(){
return <div>ImageGrid1</div>
}
}
I want to render the above component from another component using a 'var', and I cant figure out the syntax:
import React from 'react';
import ImageGrid from 'components/imageGrid';
class HomePage extends React.Component {
render() {
var div1=ImageGrid;
return (div1); // what is the proper syntax?
}
}
Upvotes: 1
Views: 49
Reputation: 27783
This is what you want.
import React from 'react';
import ImageGrid from 'components/imageGrid';
class HomePage extends React.Component {
render() {
var SomeComponent = ImageGrid;
return <SomeComponent />
}
}
Upvotes: 2