Safely parse first channel from the list, if no channels exist (#196)

This commit is contained in:
Lukasz Ostrowski 2023-02-27 09:29:12 +01:00 committed by GitHub
parent 63275866a1
commit 4e4257d788
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,6 @@
---
"saleor-app-products-feed": patch
"saleor-app-invoices": patch
---
Ensure initially selected channel will not crash if no channels exist

View file

@ -48,7 +48,7 @@ export const ChannelsConfiguration = () => {
useEffect(() => {
if (channels.isSuccess) {
setActiveChannelSlug(channels.data![0].slug ?? null);
setActiveChannelSlug(channels.data![0]?.slug ?? null);
}
}, [channels.isSuccess, channels.data]);

View file

@ -56,7 +56,7 @@ export const ChannelsConfiguration = () => {
useEffect(() => {
if (channels.isSuccess) {
setActiveChannelSlug(channels.data![0].slug ?? null);
setActiveChannelSlug(channels.data![0]?.slug ?? null);
}
}, [channels.isSuccess, channels.data]);