【发布时间】:2018-10-08 22:20:43
【问题描述】:
我是 React 新手,想将我的所有组件保存在一个文件中。如何导出多个组件并将它们保存在同一个文件中?
import React, { Component } from "react";
class MyText extends Component {
render() {
return (<div>
<h1>
Component</h1>
<p>This class component is named MyText. I can re-use it's code by simply Rendering (fancy name for calling) it by it's class name and I won't have to re type it, however many times I will need it.</p>
</div>);
};
}
class GreetName extends Component {
render() {
return (
<div>
<h1>Hello, {this.props.name}</h1>;
</div>
);
};
}
export default MyText;
【问题讨论】:
标签: javascript reactjs function components es6-class