mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 17:39:15 +00:00
use separate row component with shouldUpdate
This commit is contained in:
parent
548ddcd0fa
commit
e9a1be2e6d
4
static/js/app/components/terminal/row.jade
Normal file
4
static/js/app/components/terminal/row.jade
Normal file
@ -0,0 +1,4 @@
|
||||
.code-line
|
||||
span.code-line_counter
|
||||
.code-line_body!= this.props.row
|
||||
|
@ -1,8 +1,6 @@
|
||||
.terminal
|
||||
pre.terminal_code(ref="code")
|
||||
each row, index in this.state.data
|
||||
.code-line(key=index)
|
||||
span.code-line_counter
|
||||
.code-line_body!= row
|
||||
Row(row=row, key=index)
|
||||
|
||||
.terminal_footer(style={height: '30px'})
|
||||
|
@ -6,8 +6,20 @@ define([
|
||||
'reflux',
|
||||
'app/stores/terminal',
|
||||
'ansi_up',
|
||||
'templates/app/components/terminal/terminal'
|
||||
], function(_, React, Reflux, terminalStore, ansiUp, template) {
|
||||
'templates/app/components/terminal/terminal',
|
||||
'templates/app/components/terminal/row'
|
||||
], function(_, React, Reflux, terminalStore, ansiUp, template, rowTemplate) {
|
||||
var TerminalRow = React.createClass({
|
||||
render: rowTemplate,
|
||||
shouldComponentUpdate: function(nextProps) {
|
||||
return nextProps.row !== this.props.row;
|
||||
}
|
||||
});
|
||||
|
||||
template = template.locals({
|
||||
Row: TerminalRow
|
||||
});
|
||||
|
||||
var Component = React.createClass({
|
||||
mixins: [Reflux.ListenerMixin],
|
||||
shouldScrollBottom: true,
|
||||
|
Loading…
Reference in New Issue
Block a user