我在 React 中使用無狀態(tài)組件,我發(fā)現(xiàn)使用 Getters 有問題。對于有狀態(tài)組件(基于類的組件),它可以正常工作,但是如何在無狀態(tài)(功能組件)中使用它; // 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'.
ES6 函數(shù)式組件 React.js 中的 Getter
倚天杖
2021-08-26 17:44:13