-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support lazy screen registration (#6354)
Support lazy screen registration Add a hook where apps can register components as they are used, instead of having to register every screen before the app is launched.
- Loading branch information
Showing
9 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
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,19 @@ | ||
import Utils from './Utils'; | ||
import TestIDs from '../playground/src/testIDs'; | ||
|
||
const { elementById } = Utils; | ||
|
||
describe('Lazy Registration', () => { | ||
beforeEach(async () => { | ||
await device.relaunchApp(); | ||
await elementById(TestIDs.STACK_BTN).tap(); | ||
}); | ||
|
||
it('push and pop lazily registered screen', async () => { | ||
await elementById(TestIDs.PUSH_LAZY_BTN).tap(); | ||
await expect(elementById(TestIDs.LAZILY_REGISTERED_SCREEN_HEADER)).toBeVisible(); | ||
await elementById(TestIDs.POP_BTN).tap(); | ||
await expect(elementById(TestIDs.STACK_SCREEN_HEADER)).toBeVisible(); | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import {NavigationComponentProps} from 'react-native-navigation'; | ||
import Root from '../components/Root'; | ||
import Button from '../components/Button'; | ||
import Navigation from '../services/Navigation'; | ||
import testIDs from '../testIDs'; | ||
|
||
class LazilyRegisteredScreen extends React.Component<NavigationComponentProps> { | ||
static options() { | ||
return { | ||
topBar: { | ||
testID: testIDs.LAZILY_REGISTERED_SCREEN_HEADER, | ||
title: { | ||
text: 'Lazily Registered Screen' | ||
} | ||
} | ||
}; | ||
} | ||
|
||
constructor(props: NavigationComponentProps) { | ||
super(props); | ||
Navigation.events().bindComponent(this); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Root componentId={this.props.componentId}> | ||
<Button label='Pop' testID={testIDs.POP_BTN} onPress={this.pop} /> | ||
</Root> | ||
); | ||
} | ||
|
||
pop = () => Navigation.pop(this); | ||
} | ||
|
||
export default LazilyRegisteredScreen; |
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