You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Render passed-in components, passing a `closeThisTest` prop. Makes working around #14 possible.
* Add vertical space at the bottom of component tests, so components don't get covered by the 'Close' button.
* Bump version 0.4.0
Copy file name to clipboardExpand all lines: README.md
+62-16Lines changed: 62 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# react-native-component-viewer
2
2
A searchable list of components or scenes in your app. Handy for tweaking layout or design without needing to navigate your
3
-
app to get there.
3
+
app to get there.
4
4
5
5
Especially useful for accessing screens that are hard to get to, or for testing the design of screen in specific difficult-to-test situations (e.g. server failure).
If you pass in an anonymous functional component, you should always supply an explicit `name` option as above, because Component Viewer will not be able to reliably find out the name of your component.
105
+
106
+
If you pass in an unrendered component, Component Viewer will render it with the following props:
107
+
* closeThisTest: a 0-argument function; when called it closes the current test.
108
+
109
+
Note that the list of props that Component Viewer will supply to components may be added to in future, so it's best to use a functional component that explicitly picks out the ones you want to use.
110
+
88
111
## Making space for header and footer bars
89
112
90
113
In real app, your screens will normally have a header (and perhaps a footer). This means your actual component has a smaller space to render in.
91
114
92
115
To support this there's an optional property `wrapperStyle` on the second parameter to `addSceneTest`. This is a standard React Native View style.
93
116
94
117
Use the `padding` properties to adjust the rendering inset to your scene. You may want to store the style somewhere central in your app so
95
-
you don't have to type it out each time you use `addTestScene`.
118
+
you don't have to type it out each time you use `addTestScene`.
If you have are testing a component with a <Modal> on it, the modal may cover the 'Close' button and make it impossible to go back to the list. If your modal has its own close button then you can work around this by:
134
+
* registering your modal as a scene using addSceneTest, and
135
+
* calling the `closeThisTest` callback from your modal's close button.
then the 'Close this modal' button inside the modal will take you back to the menu.
159
+
108
160
# Registering Test Components
109
161
110
162
When testing a component such as a Button, you'll most likely want to view all the possible states of the button on a single screen
@@ -133,14 +185,15 @@ addComponentTest(
133
185
```
134
186
135
187
Multiple tests for a single component appear in the ComponentViewer list as a single entry. Tapping the entry displays a ScrollView containing all your tests.
136
-
188
+
189
+
137
190
# Usage with Redux
138
191
139
192
If you're using the `react-redux``connect` method, make sure you pass the 'unconnected' version of the component to `addTestScene`, e.g.:
140
193
141
194
```js
142
195
class MyComponent extends React.Component {
143
-
//...
196
+
//...
144
197
}
145
198
146
199
export default connect(
@@ -150,7 +203,7 @@ export default connect(
150
203
dispatch => ({
151
204
//.. mapDispatchToProps
152
205
}))(MyComponent);
153
-
206
+
154
207
// we export the connected component, but pass the
155
208
// unconnected component to addTestScene
156
209
addTestScene(<MyComponent {...testData}/>);
@@ -160,13 +213,6 @@ This way you can make sure your test scenes are completely independent of the Re
160
213
161
214
# Other options
162
215
163
-
By default the list will save and restore your last search term via `AsyncStorage`. This is useful if you have many registered tests, as it saves you from having to type the search term every time you reload.
216
+
By default the list will save and restore your last search term via `AsyncStorage`. This is useful if you have many registered tests, as it saves you from having to type the search term every time you reload.
164
217
165
218
Saving your last search can be disabled by setting the optional `saveSearch` prop to `false` on `ComponentViewer`. The default is `true`.
0 commit comments