File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -298,19 +298,23 @@ class ReactWrapper {
298298 * @param {Function } cb - callback function
299299 * @returns {ReactWrapper }
300300 */
301- setState ( state , callback = noop ) {
301+ setState ( state , callback = undefined ) {
302302 if ( this [ ROOT ] !== this ) {
303303 throw new Error ( 'ReactWrapper::setState() can only be called on the root' ) ;
304304 }
305305 if ( this . instance ( ) === null || this [ RENDERER ] . getNode ( ) . nodeType === 'function' ) {
306306 throw new Error ( 'ReactWrapper::setState() can only be called on class components' ) ;
307307 }
308- if ( typeof callback !== 'function' ) {
308+ if ( arguments . length > 1 && typeof callback !== 'function' ) {
309309 throw new TypeError ( 'ReactWrapper::setState() expects a function as its second argument' ) ;
310310 }
311311 this . instance ( ) . setState ( state , ( ) => {
312312 this . update ( ) ;
313- callback ( ) ;
313+ if ( callback ) {
314+ const adapter = getAdapter ( this [ OPTIONS ] ) ;
315+ const instance = this . instance ( ) ;
316+ adapter . invokeSetStateCallback ( instance , callback ) ;
317+ }
314318 } ) ;
315319 return this ;
316320 }
You can’t perform that action at this time.
0 commit comments