Skip to content

Commit 235b16d

Browse files
yungstersFacebook Github Bot 3
authored andcommitted
RN: Improve <Switch> Documentation
Summary: Minor improvements to the <Switch> docblock, including adding some keywords to make it easier to find. Also, I updated documentation for the deprecated platform-specific versions of the component. Reviewed By: jingc Differential Revision: D3098626 fb-gh-sync-id: 86d0f1a45eb8ac1bd9e58ac4ba9c73a4a3dfa846 fbshipit-source-id: 86d0f1a45eb8ac1bd9e58ac4ba9c73a4a3dfa846
1 parent 9b9cc6b commit 235b16d

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

Libraries/Components/Switch/Switch.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
/**
2-
* Copyright 2004-present Facebook. All Rights Reserved.
2+
* Copyright (c) 2013-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
38
*
49
* @providesModule Switch
510
* @flow
@@ -21,7 +26,15 @@ type DefaultProps = {
2126
};
2227

2328
/**
24-
* Universal two-state toggle component.
29+
* Renders a boolean input.
30+
*
31+
* This is a controlled component that requires an `onValueChange` callback that
32+
* updates the `value` prop in order for the component to reflect user actions.
33+
* If the `value` prop is not updated, the component will continue to render
34+
* the supplied `value` prop instead of the expected result of any user actions.
35+
*
36+
* @keyword checkbox
37+
* @keyword toggle
2538
*/
2639
var Switch = React.createClass({
2740
propTypes: {

Libraries/Components/SwitchAndroid/SwitchAndroid.android.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ var requireNativeComponent = require('requireNativeComponent');
2020
var SWITCH = 'switch';
2121

2222
/**
23-
* Standard Android two-state toggle component
23+
* @deprecated
24+
*
25+
* Use <Switch> instead for cross-platform compatibility.
2426
*/
2527
var SwitchAndroid = React.createClass({
2628
mixins: [NativeMethodsMixin],

Libraries/Components/SwitchIOS/SwitchIOS.ios.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ type DefaultProps = {
3232
type Event = Object;
3333

3434
/**
35-
* Use `SwitchIOS` to render a boolean input on iOS. This is
36-
* a controlled component, so you must hook in to the `onValueChange` callback
37-
* and update the `value` prop in order for the component to update, otherwise
38-
* the user's change will be reverted immediately to reflect `props.value` as the
39-
* source of truth.
35+
* @deprecated
36+
*
37+
* Use <Switch> instead for cross-platform compatibility.
4038
*/
4139
var SwitchIOS = React.createClass({
4240
mixins: [NativeMethodsMixin],

0 commit comments

Comments
 (0)