truffle-box / react-box

Truffle, Webpack and React boilerplate.
https://truffle-box.github.io/
MIT License
736 stars 251 forks source link

Unhandled Rejection (TypeError): Cannot read property '<contract method>' of null #103

Closed eunnovax closed 5 years ago

eunnovax commented 5 years ago

Hey Truffle team,

Please help to instantiate the contract before it is called within react component methods. Currently, contract is NOT instantiated before it is called. I'm receiving the above error while trying to call contract method. The error basically means React custom methods inside render() function are called BEFORE contract is instantiated.

ccccqcccc commented 5 years ago

ComponentDidMount is after render() lifecycle, so you can instantiate in before render() lifecycle method. Like constructor or unsafe_componentWillMount. But,unsafe_componentWillMount is not good solution https://ja.reactjs.org/docs/react-component.html

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been closed, but can be re-opened if further comments indicate that the problem persists. Feel free to tag maintainers if there is no reply to further comments.