A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: code editor refresh with new state (#4666)
Shahmir Varqha0233926444d2
diff --git a/frontend/src/plugins/impl/CodeEditorPlugin.tsx b/frontend/src/plugins/impl/CodeEditorPlugin.tsxindex d646715ce3..f1fa9611b3 100644--- a/frontend/src/plugins/impl/CodeEditorPlugin.tsx+++ b/frontend/src/plugins/impl/CodeEditorPlugin.tsx@@ -6,7 +6,7 @@ import { Labeled } from "./common/labeled";import { type Theme, useTheme } from "@/theme/useTheme";import { LazyAnyLanguageCodeMirror } from "./code/LazyAnyLanguageCodeMirror";import { TooltipProvider } from "@/components/ui/tooltip";-import { useCallback, useState, useMemo } from "react";+import { useCallback, useState, useMemo, useEffect } from "react";import { useDebounceControlledState } from "@/hooks/useDebounce";import { EditorView } from "@codemirror/view";import useEvent from "react-use-event-hook";@@ -71,6 +71,12 @@ const CodeEditorComponent = (props: CodeEditorComponentProps) => {disabled: !Number.isFinite(props.debounce),});+ // This is to sync the value from Python whenever the cell is updated+ // as useState doesn't reinitialize on re-renders+ useEffect(() => {+ setLocalValue(props.value);+ }, [props.value]);+const handleChange = useCallback((newValue: string) => {setLocalValue((_) => newValue);