-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fabric: State-related mounting logic for iOS
Summary: The changes allows to get the State object on mounting layer and initiate the updates. Reviewed By: mdvacca Differential Revision: D14217185 fbshipit-source-id: 370644e06e350932e93c39adbe46544b071c28b3
- Loading branch information
1 parent
802534e
commit 9207377
Showing
6 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
React/Fabric/Mounting/MountItems/RCTUpdateStateMountItem.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import <React/RCTMountItemProtocol.h> | ||
#import <React/RCTPrimitives.h> | ||
#import <react/core/State.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* Updates state of a component view. | ||
*/ | ||
@interface RCTUpdateStateMountItem : NSObject <RCTMountItemProtocol> | ||
|
||
- (instancetype)initWithTag:(ReactTag)tag | ||
oldState:(facebook::react::State::Shared)oldState | ||
newState:(facebook::react::State::Shared)newState; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
39 changes: 39 additions & 0 deletions
39
React/Fabric/Mounting/MountItems/RCTUpdateStateMountItem.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "RCTUpdateStateMountItem.h" | ||
|
||
#import "RCTComponentViewRegistry.h" | ||
|
||
using namespace facebook::react; | ||
|
||
@implementation RCTUpdateStateMountItem { | ||
ReactTag _tag; | ||
State::Shared _oldState; | ||
State::Shared _newState; | ||
} | ||
|
||
- (instancetype)initWithTag:(ReactTag)tag | ||
oldState:(facebook::react::State::Shared)oldState | ||
newState:(facebook::react::State::Shared)newState | ||
{ | ||
if (self = [super init]) { | ||
_tag = tag; | ||
_oldState = oldState; | ||
_newState = newState; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)executeWithRegistry:(RCTComponentViewRegistry *)registry | ||
{ | ||
UIView<RCTComponentViewProtocol> *componentView = [registry componentViewByTag:_tag]; | ||
[componentView updateState:_newState oldState:_oldState]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters