我有一個自定義鉤子,也有一些選擇器,需要根據兩者的組合設置最終標志。我不能簡單地編寫一個結合了以下代碼的函數,因為鉤子或選擇器都不能在react FC之外使用。使像這樣的整個塊成為某個地方的單個可重用函數的最佳方法是什么?// selector const { activeIntents, writeRole, intents, permalink } = useSelector(state => state.companyIntentsReducer);// custom hook const { hasExtendedRoleForCompany } = useJwtRoles();// func calling the custom hook const intentWrite = hasExtendedRoleForCompany("intent-manage-write", permalink);// final result combines both const editMode = writeRole && intentWrite自定義鉤子可以使用選擇器嗎?
如何組合自定義鉤子和選擇器結果?
三國紛爭
2022-08-18 10:26:51