Skip to content

Commit

Permalink
RN: Improve <Switch> Documentation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and Facebook Github Bot 3 committed Mar 25, 2016
1 parent 9b9cc6b commit 235b16d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
17 changes: 15 additions & 2 deletions Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Switch
* @flow
Expand All @@ -21,7 +26,15 @@ type DefaultProps = {
};

/**
* Universal two-state toggle component.
* Renders a boolean input.
*
* This is a controlled component that requires an `onValueChange` callback that
* updates the `value` prop in order for the component to reflect user actions.
* If the `value` prop is not updated, the component will continue to render
* the supplied `value` prop instead of the expected result of any user actions.
*
* @keyword checkbox
* @keyword toggle
*/
var Switch = React.createClass({
propTypes: {
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/SwitchAndroid/SwitchAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ var requireNativeComponent = require('requireNativeComponent');
var SWITCH = 'switch';

/**
* Standard Android two-state toggle component
* @deprecated
*
* Use <Switch> instead for cross-platform compatibility.
*/
var SwitchAndroid = React.createClass({
mixins: [NativeMethodsMixin],
Expand Down
8 changes: 3 additions & 5 deletions Libraries/Components/SwitchIOS/SwitchIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ type DefaultProps = {
type Event = Object;

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

0 comments on commit 235b16d

Please sign in to comment.