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
This commit is contained in:
Tim Yung 2016-03-25 15:16:43 -07:00 коммит произвёл Facebook Github Bot 3
Родитель 9b9cc6b543
Коммит 235b16d932
3 изменённых файлов: 21 добавлений и 8 удалений

Просмотреть файл

@ -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 * @providesModule Switch
* @flow * @flow
@ -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({ var Switch = React.createClass({
propTypes: { propTypes: {

Просмотреть файл

@ -20,7 +20,9 @@ var requireNativeComponent = require('requireNativeComponent');
var SWITCH = 'switch'; var SWITCH = 'switch';
/** /**
* Standard Android two-state toggle component * @deprecated
*
* Use <Switch> instead for cross-platform compatibility.
*/ */
var SwitchAndroid = React.createClass({ var SwitchAndroid = React.createClass({
mixins: [NativeMethodsMixin], mixins: [NativeMethodsMixin],

Просмотреть файл

@ -32,11 +32,9 @@ type DefaultProps = {
type Event = Object; type Event = Object;
/** /**
* Use `SwitchIOS` to render a boolean input on iOS. This is * @deprecated
* 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 * Use <Switch> instead for cross-platform compatibility.
* the user's change will be reverted immediately to reflect `props.value` as the
* source of truth.
*/ */
var SwitchIOS = React.createClass({ var SwitchIOS = React.createClass({
mixins: [NativeMethodsMixin], mixins: [NativeMethodsMixin],