1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: not set env if undefined

This commit is contained in:
Ivar Conradi Østhus 2021-09-27 13:17:59 +02:00
parent 236c798380
commit 139098fda9

View File

@ -42,13 +42,14 @@ const ApiTokenCreate = ({
const { environments } = useEnvironments();
useEffect(() => {
if(environments && data.type === TYPE_CLIENT && !data.environment) {
if(environments && environments.length > 0 && data.type === TYPE_CLIENT && !data.environment) {
setData({...data, environment: environments[0].name})
}
}, [data, environments]);
const clear = () => {
setData({...INITIAL_DATA});
const environment = environments && environments.length > 0 ? environments[0].name : undefined;
setData({...INITIAL_DATA, environment });
setError({});
}