Skip to content

Commit

Permalink
feat(logProps): display all props by default (#31)
Browse files Browse the repository at this point in the history
* Display all props if no prop names are provided
* Update documentation
  • Loading branch information
thibautrey authored and davidbonnet committed Jan 23, 2019
1 parent a934f67 commit fbfa30b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
withChildren,
withChild,
EMPTY_OBJECT,
logProps,
} from '../src'

const Text = compose(
Expand Down Expand Up @@ -324,6 +325,7 @@ export const App = compose(
delayable,
editable,
object,
logProps(),
)(function App(props) {
const { property } = props
return $(
Expand Down
4 changes: 3 additions & 1 deletion src/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,14 @@ export function called(object, property) {
export function logProps(propNames, title) {
/*
Logs the provided `propNames` whenever they change.
The `title` defaults to the component name.
If no `propNames` are provided, logs all props.
*/
return Component =>
onPropsChange(propNames, props => {
/* eslint-disable no-console */
console.group(title || Component.displayName || Component.name)
for (let name of propNames) {
for (let name of propNames || keys(props)) {
console.log(name, props[name])
}
console.groupEnd()
Expand Down

0 comments on commit fbfa30b

Please sign in to comment.