Skip to content

Commit 975e47a

Browse files
committed
upd
1 parent 37021fb commit 975e47a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

examples/graphiql-webpack/src/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'graphiql/style.css';
99
import '@graphiql/plugin-explorer/style.css';
1010
import '@graphiql/plugin-code-exporter/style.css';
1111
import { createGraphiQLFetcher } from '@graphiql/toolkit';
12-
import { useStorageContext } from '@graphiql/react';
12+
import { useStorage } from '@graphiql/react';
1313

1414
export const STARTING_URL =
1515
'https://swapi-graphql.netlify.app/.netlify/functions/index';
@@ -60,9 +60,9 @@ const style = { height: '100vh' };
6060
const explorer = explorerPlugin();
6161

6262
const App = () => {
63-
const storage = useStorageContext();
63+
const storage = useStorage({ nonNull: true });
6464

65-
const lastUrl = storage?.get(LAST_URL_KEY);
65+
const lastUrl = storage.get(LAST_URL_KEY);
6666
const [currentUrl, setUrl] = React.useState(lastUrl ?? STARTING_URL);
6767
// TODO: a breaking change where we make URL an internal state concern, and then expose hooks
6868
// so that you can handle/set URL state internally from a plugin

examples/graphiql-webpack/src/select-server-plugin.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import * as React from 'react';
22

33
import './select-server-plugin.css';
4-
import { useStorageContext, useSchemaContext } from '@graphiql/react';
4+
import { useStorage, useSchemaContext } from '@graphiql/react';
55

66
export const LAST_URL_KEY = 'lastURL';
77

88
export const PREV_URLS_KEY = 'previousURLs';
99

1010
const SelectServer = ({ url, setUrl }) => {
1111
const inputRef = React.useRef(null);
12-
const storage = useStorageContext();
13-
const lastUrl = storage?.get(LAST_URL_KEY);
12+
const storage = useStorage({ nonNull: true });
13+
const lastUrl = storage.get(LAST_URL_KEY);
1414
const currentUrl = lastUrl ?? url;
1515
const [inputValue, setInputValue] = React.useState(currentUrl);
1616
const [previousUrls, setPreviousUrls] = React.useState(
17-
JSON.parse(storage?.get(PREV_URLS_KEY)) ?? [currentUrl],
17+
JSON.parse(storage.get(PREV_URLS_KEY)) ?? [currentUrl],
1818
);
1919
const [error, setError] = React.useState(null);
2020

0 commit comments

Comments
 (0)