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
Update the documentation of the Button component (#29155)
Summary:
FixesMLH-Fellowship#33
The PR is part of an effort to update the code comments to match the current documentation on the React Native website. The project is a part of MLH fellowship program and involves automatic generation of the website docs from code comments and flow types as the end result.
To learn more about the project you can visit the project wiki:
- [Project details](https://github.com/MLH-Fellowship/0.4.x-projects/wiki/React-Native-Flowtype-API-Docs-Generator)
- [RN Docs Standards](https://github.com/MLH-Fellowship/react-native/wiki/RN-Docs-standards)
Link to the documentation(the source of truth):
- [button.md](https://github.com/MLH-Fellowship/react-native-website/blob/master/docs/button.md)
## Changes
* Update the title and prop description from docs.
* Remove unnecessary `*` from the code comments.
* Add default value to props.
* Specify the default value of a prop in the code comments with `default` annotation.
* For multiple defaults (different devices) use `default {platform android/ios}`.
* Update platforms in props.
* Use comma separated string with `platform` decorator.
* Add Snack player example specified in the docs to the code comments with `example` annotation.
## Changelog
[Internal]
Pull Request resolved: #29155
Test Plan:
All changes are made to the code comments and thus there is no need for testing.
[Reviewed by jevakallio](MLH-Fellowship#18)
Reviewed By: cpojer
Differential Revision: D22767877
Pulled By: motiz88
fbshipit-source-id: ccad8d58dc2888d44d34fdbb94b3c187542e9f2b
* If this button doesn't look right for your app, you can build your own
110
-
* button using [TouchableOpacity](docs/touchableopacity.html)
111
-
* or [TouchableNativeFeedback](docs/touchablenativefeedback.html).
112
-
* For inspiration, look at the [source code for this button component](https://github.com/facebook/react-native/blob/master/Libraries/Components/Button.js).
113
-
* Or, take a look at the [wide variety of button components built by the community](https://js.coach/react-native?search=button).
114
-
*
115
-
* Example usage:
116
-
*
117
-
* ```
118
-
* import { Button } from 'react-native';
119
-
* ...
120
-
*
121
-
* <Button
122
-
* onPress={onPressLearnMore}
123
-
* title="Learn More"
124
-
* color="#841584"
125
-
* accessibilityLabel="Learn more about this purple button"
126
-
* />
127
-
* ```
128
-
*
140
+
A basic button component that should render nicely on any platform. Supports a
141
+
minimal level of customization.
142
+
143
+
If this button doesn't look right for your app, you can build your own button
144
+
using [TouchableOpacity](touchableopacity) or
145
+
[TouchableWithoutFeedback](touchablewithoutfeedback). For inspiration, look at
146
+
the [source code for this button component][button:source]. Or, take a look at
147
+
the [wide variety of button components built by the community]
Adjust the color in a way that looks standard on each platform. On iOS, the color prop controls the color of the text. On Android, the color adjusts the background color of the button.
188
+
</Text>
189
+
<Button
190
+
title="Press me"
191
+
color="#f194ff"
192
+
onPress={() => Alert.alert('Button with adjusted color pressed')}
193
+
/>
194
+
</View>
195
+
<Separator />
196
+
<View>
197
+
<Text style={styles.title}>
198
+
All interaction for the component are disabled.
199
+
</Text>
200
+
<Button
201
+
title="Press me"
202
+
disabled
203
+
onPress={() => Alert.alert('Cannot press this one')}
204
+
/>
205
+
</View>
206
+
<Separator />
207
+
<View>
208
+
<Text style={styles.title}>
209
+
This layout strategy lets the title define the width of the button.
0 commit comments