Skip to content

Commit fd9b557

Browse files
committed
attempt 3
1 parent 0bf49c5 commit fd9b557

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/js/packages/@reactpy/client/src/components.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ function useImportSource(model: ReactPyVdom): MutableRefObject<any> {
175175
const mountPoint = useRef<HTMLElement>(null);
176176
const client = useContext(ClientContext);
177177
const [binding, setBinding] = useState<ImportSourceBinding | null>(null);
178+
const bindingSource = useRef<string | null>(null);
178179

179180
useEffect(() => {
180181
let unmounted = false;
@@ -184,6 +185,7 @@ function useImportSource(model: ReactPyVdom): MutableRefObject<any> {
184185
loadImportSource(vdomImportSource, client).then((bind) => {
185186
if (!unmounted && mountPoint.current) {
186187
currentBinding = bind(mountPoint.current);
188+
bindingSource.current = vdomImportSourceJsonString;
187189
setBinding(currentBinding);
188190
}
189191
});
@@ -206,6 +208,9 @@ function useImportSource(model: ReactPyVdom): MutableRefObject<any> {
206208
if (!(binding && vdomImportSource)) {
207209
return;
208210
}
211+
if (bindingSource.current !== vdomImportSourceJsonString) {
212+
return;
213+
}
209214
binding.render(model);
210215
if (vdomImportSource.unmountBeforeUpdate) {
211216
return binding.unmount;

0 commit comments

Comments
 (0)