Skip to content

Commit 5667a8c

Browse files
authored
fix: tags and fields are pointer objects, so resting with the same pointer to a stateful object is incorrect. (#5865)
1 parent f98c9bd commit 5667a8c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/dataExplorer/context/fields.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export const FieldsProvider: FC<Prop> = ({children, scope}) => {
5050
const {query: queryAPI} = useContext(QueryContext)
5151

5252
// States
53-
const [fields, setFields] = useState<Array<string>>(INITIAL_FIELDS)
53+
const [fields, setFields] = useState<Array<string>>(
54+
JSON.parse(JSON.stringify(INITIAL_FIELDS))
55+
)
5456
const [loading, setLoading] = useState<RemoteDataState>(
5557
RemoteDataState.NotStarted
5658
)
@@ -121,7 +123,7 @@ export const FieldsProvider: FC<Prop> = ({children, scope}) => {
121123
}
122124

123125
const resetFields = () => {
124-
setFields(INITIAL_FIELDS)
126+
setFields(JSON.parse(JSON.stringify(INITIAL_FIELDS)))
125127
setLoading(RemoteDataState.NotStarted)
126128
}
127129

src/dataExplorer/context/tags.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export const TagsProvider: FC<Prop> = ({children, scope}) => {
6161
const {query: queryAPI} = useContext(QueryContext)
6262

6363
// States
64-
const [tags, setTags] = useState<Tags>(INITIAL_TAGS)
64+
const [tags, setTags] = useState<Tags>(
65+
JSON.parse(JSON.stringify(INITIAL_TAGS))
66+
)
6567
const [loadingTagKeys, setLoadingTagKeys] = useState<RemoteDataState>(
6668
RemoteDataState.NotStarted
6769
)
@@ -222,7 +224,7 @@ export const TagsProvider: FC<Prop> = ({children, scope}) => {
222224
}
223225

224226
const resetTags = () => {
225-
setTags(INITIAL_TAGS)
227+
setTags(JSON.parse(JSON.stringify(INITIAL_TAGS)))
226228
setLoadingTagKeys(RemoteDataState.NotStarted)
227229
setLoadingTagValues(INITIAL_LOADING_TAG_VALUES)
228230
}

0 commit comments

Comments
 (0)