Home Reference Source Repository

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

Enhances a component with change checks and console logs powered by debugjs

since 2.0.0
public

Encapsulates the shouldUpdate logic as a high order function

since 1.0.0
Static Protected Summary
protected

Get the name of the given React component

since 1.0.0
protected

reportChanges(context: object, nProps: object, nState: object, log: function): Array<Change>

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

Params:

NameTypeAttributeDescription
context object

the component context, containing the current props and state values

nProps object

the next props in the update process

nState object

the next state in the update process

Return:

boolean

true if should update the component else false

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:

NameTypeAttributeDescription
Component React.Component

the component to be enhanced

Return:

React.Component

the enhanced component

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:

NameTypeAttributeDescription
PureComponent React.Component

the component to be enhanced

Return:

React.Component

the enhanced component

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:

NameTypeAttributeDescription
ctx object

the component context, containing the name, props and state values

Return:

string

the component name

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:

NameTypeAttributeDescription
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

Return:

Array<Change>

the changes that took place