rapid-eth / rapid-adventures

Rapid Adventures - Activate Your Life
1 stars 0 forks source link

[Component/Getter] ERC20Certificate - getCertificateData #42

Open kamescg opened 4 years ago

kamescg commented 4 years ago

Create 1 blockchain getter component in src/components/token

The query needs to read from the ERC20Certificate getCertificateData function.

function getCertificateData(bytes32 _certificateID) external view returns (string memory) {
  return certificateTypes[_certificateID].metadata;
}

Component(s) Logic

@onpaws I want to review this with you, but would be cool to write our smart contract function read components by default not include a render component. The primary responsibility is to handle the request.

Of course you could still pass children props if you wanted to render something, but it shouldn't be required and in fact maybe discouraged. It will just be a functional component that only handles this read to on-chain side-effect.

onpaws commented 4 years ago

Patrick note: "similar to containers from back in the early react days"

onpaws commented 4 years ago

Cool, just opened a PR that starts with this approach. Returns null by default, only if the consumer provides children will they be returned.

I think I follow where you're going with this.

onpaws commented 4 years ago

getters branch has wip

onpaws commented 4 years ago

when the parent has lots of children and wants to know when teh data is avail if (props.thisCallback) props.thisCallback(value)

onpaws commented 4 years ago

Consider investigating https://reactjs.org/docs/hooks-reference.html#usecallback