@@ -127,12 +127,17 @@ function getData(internalInstance: Object): DataType {
127127
128128 if ( internalInstance . _instance ) {
129129 var inst = internalInstance . _instance ;
130+
131+ // A forceUpdate for stateless (functional) components.
132+ var forceUpdate = inst . forceUpdate || ( inst . updater && inst . updater . enqueueForceUpdate && function ( cb ) {
133+ inst . updater . enqueueForceUpdate ( this , cb , 'forceUpdate' ) ;
134+ } ) ;
130135 updater = {
131136 setState : inst . setState && inst . setState . bind ( inst ) ,
132- forceUpdate : inst . forceUpdate && inst . forceUpdate . bind ( inst ) ,
133- setInProps : inst . forceUpdate && setInProps . bind ( null , internalInstance ) ,
137+ forceUpdate : forceUpdate && forceUpdate . bind ( inst ) ,
138+ setInProps : forceUpdate && setInProps . bind ( null , internalInstance , forceUpdate ) ,
134139 setInState : inst . forceUpdate && setInState . bind ( null , inst ) ,
135- setInContext : inst . forceUpdate && setInContext . bind ( null , inst ) ,
140+ setInContext : forceUpdate && setInContext . bind ( null , inst , forceUpdate ) ,
136141 } ;
137142 if ( typeof type === 'function' ) {
138143 publicInstance = inst ;
@@ -172,23 +177,23 @@ function getData(internalInstance: Object): DataType {
172177 } ;
173178}
174179
175- function setInProps ( internalInst , path : Array < string | number > , value : any ) {
180+ function setInProps ( internalInst , forceUpdate , path : Array < string | number > , value : any ) {
176181 var element = internalInst . _currentElement ;
177182 internalInst . _currentElement = {
178183 ...element ,
179184 props : copyWithSet ( element . props , path , value ) ,
180185 } ;
181- internalInst . _instance . forceUpdate ( ) ;
186+ forceUpdate . call ( internalInst . _instance ) ;
182187}
183188
184189function setInState ( inst , path : Array < string | number > , value : any ) {
185190 setIn ( inst . state , path , value ) ;
186191 inst . forceUpdate ( ) ;
187192}
188193
189- function setInContext ( inst , path : Array < string | number > , value : any ) {
194+ function setInContext ( inst , forceUpdate , path : Array < string | number > , value : any ) {
190195 setIn ( inst . context , path , value ) ;
191- inst . forceUpdate ( ) ;
196+ forceUpdate . call ( inst ) ;
192197}
193198
194199function setIn ( obj : Object , path : Array < string | number > , value : any ) {
0 commit comments