Skip to content

Commit 6ae7118

Browse files
author
Horcrux
committed
add usage information
add usage information
1 parent df9b21b commit 6ae7118

1 file changed

Lines changed: 32 additions & 5 deletions

File tree

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
### react-native-root-siblings
22
---
33

4-
Add sibling elements after your app root
5-
The created sibling elements are on the top of react-native elements in your app.
6-
This can be used to create a `Modal` component or something should be on top of app.
4+
Add sibling elements after your app root element.
5+
The created sibling elements are above the rest of your app elements.
6+
This can be used to create a `Modal` component or something should be over your app.
77

88
### Add it to your project
99

@@ -12,14 +12,41 @@ This can be used to create a `Modal` component or something should be on top of
1212

1313
```javascript
1414
...do something there
15-
**import 'react-native-root-siblings';**
15+
import 'react-native-root-siblings';
1616
...do something else
1717

18-
*AppRegistry.registerComponent('MyApp', () => MyApp);*
18+
AppRegistry.registerComponent('MyApp', () => MyApp);
1919

2020
```
2121

2222
### USAGE
23+
This library can add element above the root app component registered by `AppRegistry.registerComponent`.
24+
25+
1. Create sibling element
26+
```
27+
let sibling = new RootSiblings(<View
28+
style={{top: 0,right: 0,bottom: 0,left: 0,backgroundColor: 'red'}}
29+
/>);
30+
```
31+
This will create a View element cover all of your app elements,
32+
and returns a sibling instance.
33+
You can create a sibling anywhere inside your react native code.
34+
35+
2. Update sibling element
36+
```
37+
sibling.update(<View
38+
style={{top: 10,right: 10,bottom: 10,left: 10,backgroundColor: 'blue'}}
39+
/>);
40+
```
41+
This will update the sibling instance to a View with blue backgroundColor and cover the screen by `10` offset distance.
42+
43+
3. Destroy sibling element
44+
```
45+
sibling.destroy();
46+
```
47+
This will remove the sibling element.
48+
49+
### EXAMPLE
2350

2451
```
2552
'use strict';

0 commit comments

Comments
 (0)