Skip to content

Commit

Permalink
fix: remove [] for update depth error
Browse files Browse the repository at this point in the history
  • Loading branch information
OliwiaGowor committed Dec 6, 2024
1 parent 20d8ad7 commit 208ff59
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/header/NamespaceChooser/NamespaceChooser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function NamespaceChooser() {
/>,
];

allNamespaces.map(ns =>
allNamespaces?.map(ns =>
namespaces.push(
<SideNavigationSubItem
text={ns}
Expand Down
4 changes: 2 additions & 2 deletions src/header/NamespaceDropdown/NamespaceDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function NamespaceDropdown() {

let namespaces = [];

if (allNamespaces.length > 0) {
if (allNamespaces && allNamespaces.length > 0) {
namespaces.push(
<ComboBoxItem
text={t('navigation.all-namespaces')}
Expand All @@ -21,7 +21,7 @@ export function NamespaceDropdown() {
);
}

allNamespaces.map(ns =>
allNamespaces?.map(ns =>
namespaces.push(<ComboBoxItem text={ns} key={ns} data-key={ns} />),
);

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useAvailableNamespaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export function useAvailableNamespaces() {
};

useEffect(() => {
if (error && Array.isArray(namespaces) && namespaces.length !== 0) {
setNamespaces([]);
if (error) {
setNamespaces(null);
return;
}
const filteredNamespaces = allNamespaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export const DynamicPageComponent = ({
titleArea={headerTitle}
headerArea={customHeaderContent ?? headerContent}
selectedSectionId={selectedSectionIdState}
onSelectedSectionChange={e => {
onBeforeNavigate={e => {
if (isFormOpen.formOpen) {
e.preventDefault();
}
Expand All @@ -363,14 +363,14 @@ export const DynamicPageComponent = ({
isFormOpen,
setIsFormOpen,
() => {
setSelectedSectionIdState(e.detail.selectedSectionId);
setSelectedSectionIdState(e.detail.sectionId);
setIsResourceEdited({
isEdited: false,
});
},
);

if (e.detail.selectedSectionId === 'edit') {
if (e.detail.sectionId === 'edit') {
setIsFormOpen({ formOpen: true });
}
}}
Expand Down
4 changes: 2 additions & 2 deletions src/state/namespacesAtom.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { atom, RecoilState } from 'recoil';

export type NamespacesState = string[];
export type NamespacesState = string[] | null;

const defaultValue: string[] = [];
const defaultValue = null;

export const namespacesState: RecoilState<NamespacesState> = atom<
NamespacesState
Expand Down

0 comments on commit 208ff59

Please sign in to comment.