Skip to content

Commit 6dd7bd0

Browse files
authored
feat: persist queries (#4751)
1 parent 5237926 commit 6dd7bd0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/dataExplorer/components/ResultsPane.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
FlexDirection,
1414
JustifyContent,
1515
} from '@influxdata/clockface'
16+
import {createLocalStorageStateHook} from 'use-local-storage-state'
1617

1718
import TimeRangeDropdown from 'src/shared/components/TimeRangeDropdown'
1819
import Results from 'src/dataExplorer/components/Results'
@@ -32,6 +33,10 @@ import {DEFAULT_TIME_RANGE} from 'src/shared/constants/timeRanges'
3233
const FluxMonacoEditor = lazy(() =>
3334
import('src/shared/components/FluxMonacoEditor')
3435
)
36+
const useLocalStorageState = createLocalStorageStateHook(
37+
'dataExplorerQuery',
38+
''
39+
)
3540

3641
const INITIAL_HORIZ_RESIZER_HANDLE = 0.2
3742
const fakeNotify = notify
@@ -43,7 +48,7 @@ const ResultsPane: FC = () => {
4348
const {basic, query} = useContext(QueryContext)
4449
const {status, setStatus, setResult, setTime} = useContext(ResultsContext)
4550

46-
const [text, setText] = useState('')
51+
const [text, setText] = useLocalStorageState()
4752
const [timeRange, setTimeRange] = useState<TimeRange>(DEFAULT_TIME_RANGE)
4853

4954
const download = () => {

0 commit comments

Comments
 (0)