Skip to content

Commit b37dc2e

Browse files
doronpryogevbd
andauthored
RN Mock: push didAppear to next event loop (#7714)
This is needed to simulate real app life cycle where componentDidAppear is called after componentDidMount as per https://wix.github.io/react-native-navigation/docs/screen-lifecycle/#mounting Co-authored-by: Yogev Ben David <[email protected]>
1 parent 0868e58 commit b37dc2e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

jest-setup.js

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ beforeEach(() => {
2929
mockUILib();
3030
});
3131

32+
setImmediate = (callback) => callback();
33+
3234
const mockUILib = () => {
3335
const NativeModules = require('react-native').NativeModules;
3436
NativeModules.KeyboardTrackingViewTempManager = {};

lib/Mock/Layouts/ComponentNode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class ComponentNode extends ParentNode {
1313

1414
public componentDidMount() {
1515
this.componentDidMountOnce = true;
16-
this.componentDidAppearPending && this.componentDidAppear();
16+
this.componentDidAppearPending && setImmediate(() => this.componentDidAppear());
1717
}
1818

1919
public componentDidAppear() {

0 commit comments

Comments
 (0)