huatw / react-logger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-prop-logger

APIs

logProps

HOC logProps, log props in lifecycle methods.

// only componentDidMount
@logProps('componentDidMount')
class App extends Component {...}

// componentDidMount and componentDidUpdate
@logProps([
  'componentDidMount',
  'componentDidUpdate',
])
class App extends Component {...}

// except for shouldComponentUpdate and componentWillUnmount
@logProps({
  shouldComponentUpdate: false,
  componentWillUnmount: false
})
class App extends Component {...}

log

normal property descriptor log to intercept a function.

// log all args
@log()
shouldComponentUpdate (nextProps) {...}

// log partial
@log((nextProps, nextState) => { console.log(nextState.name) })
shouldComponentUpdate (nextProps, nextState) {...}

About


Languages

Language:JavaScript 100.0%