File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
examples/graphiql-webpack/src Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import 'graphiql/style.css';
9
9
import '@graphiql/plugin-explorer/style.css' ;
10
10
import '@graphiql/plugin-code-exporter/style.css' ;
11
11
import { createGraphiQLFetcher } from '@graphiql/toolkit' ;
12
- import { useStorageContext } from '@graphiql/react' ;
12
+ import { useStorage } from '@graphiql/react' ;
13
13
14
14
export const STARTING_URL =
15
15
'https://swapi-graphql.netlify.app/.netlify/functions/index' ;
@@ -60,9 +60,9 @@ const style = { height: '100vh' };
60
60
const explorer = explorerPlugin ( ) ;
61
61
62
62
const App = ( ) => {
63
- const storage = useStorageContext ( ) ;
63
+ const storage = useStorage ( { nonNull : true } ) ;
64
64
65
- const lastUrl = storage ? .get ( LAST_URL_KEY ) ;
65
+ const lastUrl = storage . get ( LAST_URL_KEY ) ;
66
66
const [ currentUrl , setUrl ] = React . useState ( lastUrl ?? STARTING_URL ) ;
67
67
// TODO: a breaking change where we make URL an internal state concern, and then expose hooks
68
68
// so that you can handle/set URL state internally from a plugin
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
3
3
import './select-server-plugin.css' ;
4
- import { useStorageContext , useSchemaContext } from '@graphiql/react' ;
4
+ import { useStorage , useSchemaContext } from '@graphiql/react' ;
5
5
6
6
export const LAST_URL_KEY = 'lastURL' ;
7
7
8
8
export const PREV_URLS_KEY = 'previousURLs' ;
9
9
10
10
const SelectServer = ( { url, setUrl } ) => {
11
11
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 ) ;
14
14
const currentUrl = lastUrl ?? url ;
15
15
const [ inputValue , setInputValue ] = React . useState ( currentUrl ) ;
16
16
const [ previousUrls , setPreviousUrls ] = React . useState (
17
- JSON . parse ( storage ? .get ( PREV_URLS_KEY ) ) ?? [ currentUrl ] ,
17
+ JSON . parse ( storage . get ( PREV_URLS_KEY ) ) ?? [ currentUrl ] ,
18
18
) ;
19
19
const [ error , setError ] = React . useState ( null ) ;
20
20
You can’t perform that action at this time.
0 commit comments