Is it generally better to define a contract instance once, then pass it through your components like...
class Parent extends React.Component{
constructor(props){
super(props);
this.state={
contract = new contract(contract.abi, contract.address)
}
}
render() {
return{
<div>
<Child contract={this.state.contract}/>
</div>
}
}
}
class child extends React.Component{
constructor(props){
super(props);
}
async function = () => {
//use this.props.library in here to call contract methods
}
render() {
return{
<div>
<other stuff />
</div>
}
}
}
Or is it alright to define a new contract instance every time you need to use it?
class Parent extends React.Component{
constructor(props){
super(props);
}
render() {
return{
<div>
<Child />
</div>
}
}
}
class child extends React.Component{
constructor(props){
super(props);
}
async function = () => {
//use this.state.library in here to call contract methods
}
render() {
return{
<div>
<other stuff />
</div>
}
}
}