We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// textbox component export function TextBox({text}){ return <div>{"文本是"+text}</div> } // 引用 import ...; import TextBox from 'textbox'; class HelloWorld extend React.Component{ // ... render(){ return <TextBox text='hello world' /> } }
// TimerMixin export default function TimerMixin(){ return { run:function(){ //...}, timer:0 } } // 对react组件的扩展,文档v0.13 上我们可以看到, mixin 不再被ES6 所支持 import TimerMixin from 'TimerMixin'; class Helloworld extend React.Component{ mixins:[TimerMixin()], // ... componentWillMount(){ this.run(); } render(){ return <div>{"Now timer is :"+this.timer}</div> } }
// 可以当成是一种组件的扩展方式 // createDialog 一个扩展dialog组件的函数 export default function createDialog(Component){ return class BiggerDialog extend React.Component{ // ... componentWillMount(){ //do something } render(){ <Component someotherparam={this.state.other} params={...this.props} /> } } } // 使用的地方 import Dialog from 'dialog-component'; import createDialog from 'createdialog'; ReactDOM.render(createDialog(Dialog));
高性能的React组件 无状态组件(Stateless Component) 与高阶组件
The text was updated successfully, but these errors were encountered:
No branches or pull requests
无状态组件(StatelessComponent)
Mixins
高阶组件(High Order Componet)
部分参考资料
高性能的React组件
无状态组件(Stateless Component) 与高阶组件
The text was updated successfully, but these errors were encountered: