From fbfa30b0ae5b44c3b324dce91f0200054738dcfc Mon Sep 17 00:00:00 2001 From: Thibaut Rey Date: Wed, 23 Jan 2019 15:04:46 +0100 Subject: [PATCH] feat(logProps): display all props by default (#31) * Display all props if no prop names are provided * Update documentation --- demo/index.js | 2 ++ src/tools.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/demo/index.js b/demo/index.js index 4a8b6555..3a1c3c74 100644 --- a/demo/index.js +++ b/demo/index.js @@ -34,6 +34,7 @@ import { withChildren, withChild, EMPTY_OBJECT, + logProps, } from '../src' const Text = compose( @@ -324,6 +325,7 @@ export const App = compose( delayable, editable, object, + logProps(), )(function App(props) { const { property } = props return $( diff --git a/src/tools.js b/src/tools.js index ef3a1a5e..5629f0b5 100644 --- a/src/tools.js +++ b/src/tools.js @@ -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()