The Debug component can be used to get a formatted JSON printout of an object. It also provides a HOC for logging props when a component uses the implicit return.
The Debug component takes an object as a children
prop.
This can be used to inspect data, props, or any object you might have in state.
import React from 'react'
import { Debug } from '@compositor/kit'
export default () =>
<Debug children={{ an: 'object' }} />
Name | Type | Required | Description |
---|---|---|---|
log |
Boolean | false |
Log object to the console |
Sometimes it can be a pain to inspect the props of a component using an explicit return during development. withDebug is a HOC to log props to the console for inspection.
import React from 'react'
import { withDebug } from '@compositor/kit'
export default withDebug(props =>
<MyComponent {...props} />
)
Name | Type | Required | Description |
---|---|---|---|
Component |
Function | true |
The component whose props you'd like to log |