From 3db12ce7121a050b533476958ff3d66ded1c4bb8 Mon Sep 17 00:00:00 2001 From: Rodolfo Silva Date: Mon, 3 Dec 2018 18:39:57 -0300 Subject: [PATCH] Add examples for renameProp and renameProps (#765) Following the issue #337, I've decided add examples for renameProp and renameProps. --- docs/API.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/API.md b/docs/API.md index 374626a5..b57b7a0c 100644 --- a/docs/API.md +++ b/docs/API.md @@ -196,6 +196,25 @@ renameProp( Renames a single prop. +Example: + +```js +const enhance = compose( + withProps({ 'loadingDataFromApi': true, 'posts': [] }), + renameProp('loadingDataFromApi', 'isLoading'), + renameProp('posts', 'items'), +); + +const Posts = enhance(({ isLoading, items }) => ( +
+
Loading: { isLoading ? 'yes' : 'no'}
+ +
+)); +``` + ### `renameProps()` ```js @@ -206,6 +225,24 @@ renameProps( Renames multiple props, using a map of old prop names to new prop names. +Example: + +```js +const enhance = compose( + withProps({ 'loadingDataFromApi': true, 'posts': [] }), + renameProps({ 'loadingDataFromApi': 'isLoading', 'posts': 'items' }), +); + +const Posts = enhance(({ isLoading, items }) => ( +
+
Loading: { isLoading ? 'yes' : 'no'}
+ +
+)); +``` + ### `flattenProp()` ```js