From 844f79370dd88c73c12624167289d99ca06cd9cd Mon Sep 17 00:00:00 2001 From: Paul Mizel Date: Tue, 24 Jul 2018 12:30:45 +0200 Subject: [PATCH] Added render props method to ContractData and to readme --- README.md | 2 ++ src/ContractData.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 84c6fb8..2229674 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ This components wraps your entire app (but within the DrizzleProvider) and will `toAscii` (boolean) Converts the return value to an Ascii string before display. +`render` ((data) => void) Provide your own rendering of the return value. + ### ContractForm `contract` (string, required) Name of the contract whose method will be the basis the form. diff --git a/src/ContractData.js b/src/ContractData.js index 6bac43c..3d2ab31 100644 --- a/src/ContractData.js +++ b/src/ContractData.js @@ -64,6 +64,10 @@ class ContractData extends Component { displayData = this.context.drizzle.web3.utils.hexToAscii(displayData) } + if (this.props.render) { + return this.props.render(displayData); + } + // If return value is an array if (typeof displayData === 'array') { const displayListItems = displayData.map((datum, index) => { @@ -77,7 +81,7 @@ class ContractData extends Component { ) } - // If retun value is an object + // If return value is an object if (typeof displayData === 'object') { var i = 0 const displayObjectProps = []