React-组件中推荐多少个功能?

时间:2018-12-13 05:27:09

标签: javascript reactjs function components

我很好奇要创建反应的一个组成部分。

在创建组件时,用于render()的函数数量有所增加。

example.js中的日历组件(render())看起来像。

render() {

    const { isToday } = this.state;
    return (
        <div className='calendar_area'>
            <div className='calendar_header'>
                <strong className='calendar_title'>
                    <button 
                        className='btn btn-sm'
                        onClick={ this.handleTogglePrevMonth }>&lt;</button>
                    { this.createCalendarTitle() }
                    { isToday && (<button 
                        className='btn btn-sm'
                        onClick={ this.handleToggleGoToday }>
                        {/* TODO
                        select month || day === current month || today ? no show : show */}
                        Today
                    </button>) }
                    <button 
                        className='btn btn-sm'
                        onClick={ this.handleToggleNextMonth }>&gt;</button>
                </strong>
            </div>
            <div className='calendar_body'>
                <table className='calendar_table'>
                    <thead className='calendar_table_header'>
                        { this.createCalendarTableHeader() }
                    </thead>
                    <tbody className='calendar_table_body'>
                        { this.createCalendarTableBody() }
                    </tbody>
                </table>
            </div>
        </div>
    )
}

render()中使用了六个函数,还创建了重用函数。因此共有八个功能。

不包括导入声明,“类〜扩展组件”和“导出默认值”的总行数为165行,并且还会添加更多行。我想知道是否需要创建另一个js文件来创建组件,或者是否可以继续写入单个文件。 我可以判断一个组件中是否存在合理数量的功能吗?

0 个答案:

没有答案