Last active
September 26, 2022 10:01
-
-
Save shiburagi/d9b1323520c72c0784ddf1791e677c16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useVoucherParameter = (key) => { | |
const [params, setParams] = useState({}) | |
const findRef = useRef(); | |
useLayoutEffect(() => { | |
VoucherApi.initParameter().then({ | |
complete: (res, e) => { | |
if (res.data) { | |
const params = res.data | |
// params.MinAmount = 600 | |
setParams(params); | |
findRef.current = (parameterKey, findId) => { | |
return res.data[parameterKey]?.find(({ Id }) => Id === findId) | |
} | |
} | |
} | |
}) | |
}, [key]); | |
return [params, findRef.current] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment