@@ -104,10 +104,10 @@ export interface LogEntry {
104
104
}
105
105
106
106
export interface ConsoleProps {
107
- handler ( command : string ) : any ;
108
- cancel ?( ) : any ;
109
- complete ?( words : string [ ] , curr : number , promptText : string ) : string [ ] ;
110
- continue ?( promptText : string ) : boolean ;
107
+ handler : ( command : string ) => any ;
108
+ cancel ?: ( ) => any ;
109
+ complete ?: ( words : string [ ] , curr : number , promptText : string ) => string [ ] ;
110
+ continue ?: ( promptText : string ) => boolean ;
111
111
autofocus ?: boolean ;
112
112
promptLabel ?: string | ( ( ) => string ) ;
113
113
welcomeMessage ?: string ;
@@ -168,7 +168,6 @@ export default class extends React.Component<ConsoleProps,ConsoleState> {
168
168
promptLabel : '> ' ,
169
169
continue : function ( ) { return false ; } ,
170
170
cancel : function ( ) { } ,
171
- handler : function ( ) { this . return ( ) } ,
172
171
} ;
173
172
child : {
174
173
typer ?: HTMLTextAreaElement ;
@@ -190,12 +189,16 @@ export default class extends React.Component<ConsoleProps,ConsoleState> {
190
189
log : log ,
191
190
} , this . scrollIfBottom ( ) ) ;
192
191
}
193
- return = ( ) => {
192
+ done = ( ) => {
194
193
this . setState ( {
195
194
acceptInput : true ,
196
195
currLabel : this . nextLabel ( ) ,
197
196
} , this . scrollIfBottom ( ) ) ;
198
197
}
198
+ return = ( ) => {
199
+ console . log ( "WARNING: return() is deprecated. Use done() or the callback (2nd arg of handler) instead." ) ;
200
+ this . done ( ) ;
201
+ }
199
202
// Component Lifecycle
200
203
componentDidMount ( ) {
201
204
if ( this . props . autofocus ) {
@@ -528,7 +531,11 @@ export default class extends React.Component<ConsoleProps,ConsoleState> {
528
531
lastCommand : ConsoleCommand . Default ,
529
532
} , ( ) => {
530
533
this . scrollToBottom ( ) ;
531
- this . props . handler ( command ) ;
534
+ if ( this . props . handler ) {
535
+ this . props . handler ( command )
536
+ } else {
537
+ this . done ( ) ;
538
+ }
532
539
} ) ;
533
540
}
534
541
}
0 commit comments