Skip to content

Commit

Permalink
iOS Surface: properly reset some internal states when JS reloads
Browse files Browse the repository at this point in the history
Summary:
There are a few important states that didn't reset correctly when reloading JS:
* the RCTSurfaceStage was stuck at all bits enabled, hence no further stage change happened (even though the state "reset" to `RCTSurfaceStageBridgeDidLoad`)
* the RCTSurfaceView didn't get recreated, because the _view ivar was never cleared
* similarly, the _touchHandler ivar attached to the _view was never re-setup --> all touches after JS reload were dropped before this diff

Reviewed By: mmmulani

Differential Revision: D7178038

fbshipit-source-id: ba49bc205f8bf43842471b7ab748cef8549ea212
  • Loading branch information
fkgozali authored and facebook-github-bot committed Mar 7, 2018
1 parent ec88489 commit cade297
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions React/Base/Surface/RCTSurface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ - (void)handleBridgeWillLoadJavaScriptNotification:(NSNotification *)notificatio
{
RCTAssertMainQueue();

// Reset states because the bridge is reloading. This is similar to initialization phase.
_stage = RCTSurfaceStageSurfaceDidInitialize;
_view = nil;
_touchHandler = nil;
[self _setStage:RCTSurfaceStageBridgeDidLoad];
}

Expand Down

0 comments on commit cade297

Please sign in to comment.