Skip to content

Commit

Permalink
Improve resfresh control doc
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis committed Mar 12, 2016
1 parent 4a89c64 commit c2d4419
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
42 changes: 41 additions & 1 deletion Libraries/Components/RefreshControl/RefreshControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,49 @@ if (Platform.OS === 'android') {
}

/**
* This component is used inside a ScrollView to add pull to refresh
* This component is used inside a ScrollView or ListView to add pull to refresh
* functionality. When the ScrollView is at `scrollY: 0`, swiping down
* triggers an `onRefresh` event.
*
* ### Usage example
*
* ``` js
* class RefreshableList extends Component {
* constructor(props) {
* super(props);
* this.state = {
* refreshing: false,
* };
* }
*
* _onRefresh() {
* this.setState({refreshing: true});
* fetchData().then(() => {
* this.setState({refreshing: false});
* });
* }
*
* render() {
* return (
* <ListView
* refreshControl={
* <RefreshControl
* refreshing={this.state.refreshing}
* onRefresh={this._onRefresh.bind(this)}
* />
* }
* ...
* >
* ...
* </ListView>
* );
* }
* ...
* }
* ```
*
* __Note:__ `refreshing` is a controlled prop, this is why it needs to be set to true
* in the `onRefresh` function otherwise the refresh indicator will stop immediatly.
*/
const RefreshControl = React.createClass({
statics: {
Expand Down
8 changes: 4 additions & 4 deletions website/layout/AutodocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ function renderType(type) {
return '{' + Object.keys(type.value).map((key => key + ': ' + renderType(type.value[key]))).join(', ') + '}';
}

if (type.name == 'union') {
if (type.name === 'union') {
return type.value.map(renderType).join(', ');
}

if (type.name === 'arrayOf') {
return '[' + renderType(type.value) + ']';
return <span>[{renderType(type.value)}]</span>;
}

if (type.name === 'instanceOf') {
Expand All @@ -56,10 +56,10 @@ function renderType(type) {
if (type.name === 'custom') {
if (styleReferencePattern.test(type.raw)) {
var name = type.raw.substring(0, type.raw.indexOf('.'));
return <a href={'docs/' + slugify(name) + '.html#style'}>{name}#style</a>
return <a href={'docs/' + slugify(name) + '.html#style'}>{name}#style</a>;
}
if (type.raw === 'ColorPropType') {
return <a href={'docs/colors.html'}>color</a>
return <a href={'docs/colors.html'}>color</a>;
}
if (type.raw === 'EdgeInsetsPropType') {
return '{top: number, left: number, bottom: number, right: number}';
Expand Down

0 comments on commit c2d4419

Please sign in to comment.