Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

Commit

Permalink
Fix inconsistencies in documentation and code
Browse files Browse the repository at this point in the history
  • Loading branch information
derekjuber authored and fusion-bot[bot] committed Jul 20, 2018
1 parent 261ff8c commit 3ca55f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ import { prepared } from 'fusion-react-async';
const hoc = prepared(sideEffect, opts);
```

* `sideEffect: : (props: Object, context: Object) => Promise` - Required. when `prepare` is called, `sideEffect` is called (and awaited) before continuing the rendering traversal.
* `sideEffect: (props: Object, context: Object) => Promise` - Required. When `prepare` is called, `sideEffect` is called (and awaited) before continuing the rendering traversal.
* `opts: {defer, boundary, componentDidMount, componentWillReceiveProps, componentDidUpdate, forceUpdate, contextTypes}` - Optional
* `defer: boolean` - Optional. Defaults to `true`. If the component is deferred, skip the prepare step
* `boundary: boolean` - Optional. Defaults to `false`. Stop traversing if the component is defer or boundary
* `defer: boolean` - Optional. Defaults to `false`. If the component is deferred, skip the prepare step.
* `boundary: boolean` - Optional. Defaults to `false`. Stop traversing if the component is defer or boundary.
* `componentDidMount: boolean` - Optional. Defaults to `true`. On the browser, `sideEffect` is called when the component is mounted.
* [TO BE DEPRECATED] `componentWillReceiveProps: boolean` - Optional. Defaults to `false`. On the browser, `sideEffect` is called again whenever the component receive props.
* `componentDidUpdate: boolean` - Optional. Defaults to `false`. On the browser, `sideEffect` is called again right after updating occurs.
* `forceUpdate: boolean` - Optional. Defaults to `false`.
* `contextTypes: Object` - Optional. Custom React context types to add to the prepared component.
* `hoc: (Component: React.Component) => React.Component` - A higher-order component that returns a component that awaits for async side effects before rendering
* `hoc: (Component: React.Component) => React.Component` - A higher-order component that returns a component that awaits for async side effects before rendering.
* `Component: React.Component` - Required.

#### exclude
Expand Down
10 changes: 5 additions & 5 deletions src/prepared.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import React, {Component} from 'react';
import {REACT_PREPARE} from './constants';

// $FlowFixMe
const prepared = (prepare, opts = {}) => OriginalComponent => {
const prepared = (sideEffect, opts = {}) => OriginalComponent => {
opts = Object.assign(
{
boundary: false,
Expand All @@ -25,7 +25,7 @@ const prepared = (prepare, opts = {}) => OriginalComponent => {
opts
);
const prep = {
prepare: (...args) => Promise.resolve(prepare(...args)),
prepare: (...args) => Promise.resolve(sideEffect(...args)),
defer: opts.defer,
};
// Disable eslint for deprecated componentWillReceiveProps
Expand All @@ -39,7 +39,7 @@ const prepared = (prepare, opts = {}) => OriginalComponent => {
}
componentDidMount() {
if (opts.componentDidMount) {
Promise.resolve(prepare(this.props, this.context)).then(() => {
Promise.resolve(sideEffect(this.props, this.context)).then(() => {
if (opts.forceUpdate) {
this.forceUpdate(); // TODO(#10) document
}
Expand All @@ -50,13 +50,13 @@ const prepared = (prepare, opts = {}) => OriginalComponent => {
// $FlowFixMe
componentWillReceiveProps(nextProps, nextContext) {
if (opts.componentWillReceiveProps) {
prepare(nextProps, nextContext);
sideEffect(nextProps, nextContext);
}
}

componentDidUpdate() {
if (opts.componentDidUpdate) {
prepare(this.props, this.context);
sideEffect(this.props, this.context);
}
}

Expand Down

0 comments on commit 3ca55f4

Please sign in to comment.