Skip to content

Commit b8fffe3

Browse files
authored
chore: migrate extensibilitySchemasState to jotai (#4139)
1 parent f1f47c0 commit b8fffe3

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/components/BusolaExtensions/BusolaExtensionDetails.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ExternalLink } from 'shared/components/ExternalLink/ExternalLink';
22
import { Trans, useTranslation } from 'react-i18next';
33
import { createPatch } from 'rfc6902';
44
import { Button, MessageStrip } from '@ui5/webcomponents-react';
5-
import { useRecoilValue } from 'recoil';
5+
import { useAtomValue } from 'jotai';
66

77
import { EMPTY_TEXT_PLACEHOLDER } from 'shared/constants';
88
import { ControlledBy } from 'shared/components/ControlledBy/ControlledBy';
@@ -34,7 +34,7 @@ import { configFeaturesNames } from 'state/types';
3434

3535
export function BusolaExtensionDetails({ name, namespace }) {
3636
const { t } = useTranslation();
37-
const extensibilitySchemas = useRecoilValue(extensibilitySchemasState);
37+
const extensibilitySchemas = useAtomValue(extensibilitySchemasState);
3838

3939
const { clusterUrl } = useUrl();
4040

src/state/extensibilitySchemasAtom.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { useEffect } from 'react';
2+
import { atom, useSetAtom } from 'jotai';
23
import { authDataState } from 'state/authDataAtom';
34
import { clusterState } from 'state/clusterAtom';
45
import jsyaml from 'js-yaml';
5-
import { atom, RecoilState, useSetRecoilState, useRecoilValue } from 'recoil';
6+
import { useRecoilValue } from 'recoil';
67

78
type ExtensibilitySchema = any;
89
interface ExtensiblitySchemas {
@@ -17,7 +18,7 @@ const getSchema = async (schema: string): Promise<ExtensibilitySchema> => {
1718
};
1819

1920
export const useGetExtensibilitySchemas = async () => {
20-
const setSchemas = useSetRecoilState(extensibilitySchemasState);
21+
const setSchemas = useSetAtom(extensibilitySchemasState);
2122
const cluster = useRecoilValue(clusterState);
2223
const auth = useRecoilValue(authDataState);
2324

@@ -46,9 +47,5 @@ export const useGetExtensibilitySchemas = async () => {
4647
}, [cluster, auth]);
4748
};
4849

49-
export const extensibilitySchemasState: RecoilState<ExtensiblitySchemas | null> = atom<ExtensiblitySchemas | null>(
50-
{
51-
key: 'extensibilitySchemasState',
52-
default: {},
53-
},
54-
);
50+
export const extensibilitySchemasState = atom<ExtensiblitySchemas | null>({});
51+
extensibilitySchemasState.debugLabel = 'extensibilitySchemasState';

0 commit comments

Comments
 (0)