Skip to content

Commit

Permalink
fix: Remove setState calls when component is unmounted
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak committed Dec 17, 2024
1 parent 1b57656 commit 78b6736
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/client/components/jsonRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ const JsonRenderer = ({ data, expansionLevel }: JsonRendererProps) => {
const [json, setJson] = useState(originalData)

useEffect(() => {
setJson(data)
let mounted = true
if (mounted) {
setJson(data)
}
return () => {
mounted = false
}
}, [data])

if (typeof json === "string") {
Expand Down

0 comments on commit 78b6736

Please sign in to comment.