Skip to content

Commit

Permalink
Added render props method to ContractData and to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Mizel committed Jul 24, 2018
1 parent f31b20a commit 844f793
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion src/ContractData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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 = []
Expand Down

0 comments on commit 844f793

Please sign in to comment.