Skip to content

Commit

Permalink
fix: Remove setState calls when component is unmounted (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak authored Jan 9, 2025
1 parent 1b57656 commit 36c5a1a
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 36c5a1a

Please sign in to comment.