Function
Static Public Summary | ||
public |
shouldUpdate(context: object, nProps: object, nState: object): boolean Simply checks if a component update is needed |
since 1.0.0 |
public |
withDebugInfo(Component: React.Component): React.Component Enhances a component with change checks and console logs powered by debugjs |
since 2.0.0 |
public |
withPureRender(PureComponent: React.Component): React.Component Encapsulates the shouldUpdate logic as a high order function |
since 1.0.0 |
Static Protected Summary | ||
protected |
getComponentName(ctx: object): string Get the name of the given React component |
since 1.0.0 |
protected |
Log and return the changes in a component as they occur to help with debugging |
since 1.0.0 |
Static Public
public shouldUpdate(context: object, nProps: object, nState: object): boolean since 1.0.0 source
import {shouldUpdate} from 'react-update-helper/src/index.js'
Simply checks if a component update is needed
public withDebugInfo(Component: React.Component): React.Component since 2.0.0 source
import {withDebugInfo} from 'react-update-helper/src/index.js'
Enhances a component with change checks and console logs powered by debugjs
Params:
Name | Type | Attribute | Description |
Component | React.Component | the component to be enhanced |
Example:
// Usage as a high order component
class MyComponent extends React.Component {
render() { return <p>Hello World!</p>; }
}
withDebugInfo(MyComponent); // Your enhanced component
public withPureRender(PureComponent: React.Component): React.Component since 1.0.0 source
import {withPureRender} from 'react-update-helper/src/index.js'
Encapsulates the shouldUpdate logic as a high order function
Params:
Name | Type | Attribute | Description |
PureComponent | React.Component | the component to be enhanced |
Example:
// Usage as a high order component
class MyComponent extends React.Component {
render() { return <p>Hello World!</p>; }
}
withPureRender(MyComponent); // Your enhanced component
Static Protected
protected getComponentName(ctx: object): string since 1.0.0 source
import {getComponentName} from 'react-update-helper/src/util.js'
Get the name of the given React component
Params:
Name | Type | Attribute | Description |
ctx | object | the component context, containing the name, props and state values |
protected reportChanges(context: object, nProps: object, nState: object, log: function): Array<Change> since 1.0.0 source
import {reportChanges} from 'react-update-helper/src/debug.js'
Log and return the changes in a component as they occur to help with debugging
Params:
Name | Type | Attribute | Description |
context | object | the component context |
|
context.props | object | the component props object |
|
context.state | object | the component state object |
|
nProps | object | the next props in the update process |
|
nState | object | the next state in the update process |
|
log | function | the log function to use when logging changes |