Skip to content

Commit

Permalink
sync when opening modal
Browse files Browse the repository at this point in the history
  • Loading branch information
yhattav committed Jan 15, 2025
1 parent 7e8ada7 commit 107459c
Showing 1 changed file with 8 additions and 32 deletions.
40 changes: 8 additions & 32 deletions src/components/JsonScenarioPanel/JsonScenarioPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";
import Editor, { OnChange } from "@monaco-editor/react";
import { Scenario } from "../../types/scenario";
Expand All @@ -21,37 +21,13 @@ export const JsonScenarioPanel: React.FC<JsonScenarioPanelProps> = ({
getCurrentScenario,
}) => {
const [jsonError, setJsonError] = useState<string | null>(null);
const [editorContent, setEditorContent] = useState<string>(`{
"id": "custom-scenario",
"name": "Custom Scenario",
"description": "A custom scenario loaded from JSON",
"data": {
"settings": {
"NEW_PARTICLE_MASS": 0.02,
"NEW_PARTICLE_ELASTICITY": 0.8,
"FRICTION": 1,
"POINTER_MASS": 500000
},
"gravityPoints": [
{
"x": 300,
"y": 300,
"label": "Custom Point",
"mass": 1000000
}
],
"particles": [
{
"id": "particle-1",
"position": { "x": 200, "y": 200 },
"velocity": { "x": 0, "y": 30 },
"mass": 0.03,
"elasticity": 0.8
}
],
"paths": []
}
}`);
const [editorContent, setEditorContent] = useState<string>("");

useEffect(() => {
if (isOpen) {
handleLoadCurrentState();
}
}, [isOpen]);

Check warning on line 30 in src/components/JsonScenarioPanel/JsonScenarioPanel.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has a missing dependency: 'handleLoadCurrentState'. Either include it or remove the dependency array

const handleEditorChange: OnChange = (value) => {
setEditorContent(value || "");
Expand Down

0 comments on commit 107459c

Please sign in to comment.