I am using stateless component in React and I found issue with using Getters.
for the statefull component (class based component) it is properly working but how can I use this in stateless(functional component);
// this is code for statefull component(class based component)
get lookupsOfSelectedGroup(){
const lookUps = this.props.mainLookups.filter(
item => item.extras.parent === this.state.activeGroup
);
if (lookUps[0] && lookUps[0].responseStatus === 200) {
return lookUps[0].response.lookup;
}
return [];
}
// this is the code for functional component I did:
get lookupsOfSelectedGroup =()=> {
const lookUps = this.props.mainLookups.filter(
item => item.extras.parent === this.state.activeGroup
);
if (lookUps[0] && lookUps[0].responseStatus === 200) {
return lookUps[0].response.lookup;
}
return [];
} ```
Cannot find name 'get'.
You can only use the get and set keywords in ES6 classes and object literals.
Check the reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With