@@ -120,6 +120,32 @@ var FrameRow = React.createFactory(React.createClass({
120
120
121
121
displayName : "FrameRow" ,
122
122
123
+ getInitialState ( ) {
124
+ return { } ;
125
+ } ,
126
+
127
+ /**
128
+ * Create TreeView sub-components in lifecycle methods so we
129
+ * only generate them once and don't run into state issues
130
+ * with the TreeView component.
131
+ */
132
+ componentWillMount ( ) {
133
+ if ( this . props . frame ) {
134
+ this . setState ( { payload : this . buildPayload ( this . props . frame ) } ) ;
135
+ }
136
+ } ,
137
+
138
+ /**
139
+ * Create TreeView sub-components in lifecycle methods so we
140
+ * only generate them once and don't run into state issues
141
+ * with the TreeView component.
142
+ */
143
+ componentWillReceiveProps ( { frame } ) {
144
+ if ( frame !== this . props . frame ) {
145
+ this . setState ( { payload : this . buildPayload ( this . props . frame ) } ) ;
146
+ }
147
+ } ,
148
+
123
149
/**
124
150
* Frames need to be re-rendered only if the selection changes.
125
151
* This is an optimization that makes the list rendering a lot faster.
@@ -136,22 +162,8 @@ var FrameRow = React.createFactory(React.createClass({
136
162
}
137
163
} ,
138
164
139
- render : function ( ) {
140
- var frame = this . props . frame ;
141
- var data = frame . data ;
142
-
143
- var className = "frameRow " + ( frame . sent ? "send" : "receive" ) ;
144
- var tooltipText = frame . sent ? "Sent" : "Received" ;
145
-
146
- if ( this . props . selection == frame ) {
147
- className += " selected" ;
148
- }
149
-
165
+ buildPayload ( frame ) {
150
166
var payload ;
151
- var size = Str . formatSize ( data . payload . length ) ;
152
- var time = new Date ( data . timeStamp / 1000 ) ;
153
- var timeText = time . getHours ( ) + ":" + time . getMinutes ( ) +
154
- ":" + time . getSeconds ( ) + "." + time . getMilliseconds ( ) ;
155
167
156
168
// Test support for inline previews.
157
169
if ( frame . socketIo ) {
@@ -171,9 +183,28 @@ var FrameRow = React.createFactory(React.createClass({
171
183
} ) ;
172
184
} else {
173
185
// Fall back to showing a string
174
- payload = Str . cropString ( data . payload , 50 ) ;
186
+ payload = Str . cropString ( frame . data . payload , 50 ) ;
187
+ }
188
+ return payload ;
189
+ } ,
190
+
191
+ render : function ( ) {
192
+ var frame = this . props . frame ;
193
+ var payload = this . state . payload ;
194
+ var data = frame . data ;
195
+
196
+ var className = "frameRow " + ( frame . sent ? "send" : "receive" ) ;
197
+ var tooltipText = frame . sent ? "Sent" : "Received" ;
198
+
199
+ if ( this . props . selection == frame ) {
200
+ className += " selected" ;
175
201
}
176
202
203
+ var size = Str . formatSize ( data . payload . length ) ;
204
+ var time = new Date ( data . timeStamp / 1000 ) ;
205
+ var timeText = time . getHours ( ) + ":" + time . getMinutes ( ) +
206
+ ":" + time . getSeconds ( ) + "." + time . getMilliseconds ( ) ;
207
+
177
208
return (
178
209
tr ( { className : className , onClick : this . onClick } ,
179
210
td ( { className : "direction" } ,
0 commit comments