Skip to content

Commit

Permalink
fix: make sure comp.instance exists (#10207)
Browse files Browse the repository at this point in the history
* fix: make sure `comp.instance` exists

* add changeset

* fix: update syntax

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
Col0ring and gradio-pr-bot authored Dec 17, 2024
1 parent 13a83e5 commit 314a8b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/wild-chicken-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/core": patch
"gradio": patch
---

fix:fix: make sure `comp.instance` exists
8 changes: 4 additions & 4 deletions js/core/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export function create_components(initial_layout: ComponentMeta | undefined): {
if (!comp) {
return null;
}
if (comp.instance.get_value) {
if (comp.instance?.get_value) {
return comp.instance.get_value() as Promise<any>;
}
return comp.props.value;
Expand Down Expand Up @@ -414,7 +414,7 @@ export function create_components(initial_layout: ComponentMeta | undefined): {
state: "open" | "closed" | "waiting"
): void {
const comp = _component_map.get(id);
if (comp && comp.instance.modify_stream_state) {
if (comp?.instance?.modify_stream_state) {
comp.instance.modify_stream_state(state);
}
}
Expand All @@ -423,14 +423,14 @@ export function create_components(initial_layout: ComponentMeta | undefined): {
id: number
): "open" | "closed" | "waiting" | "not_set" {
const comp = _component_map.get(id);
if (comp && comp.instance.get_stream_state)
if (comp?.instance?.get_stream_state)
return comp.instance.get_stream_state();
return "not_set";
}

function set_time_limit(id: number, time_limit: number | undefined): void {
const comp = _component_map.get(id);
if (comp && comp.instance.set_time_limit) {
if (comp?.instance?.set_time_limit) {
comp.instance.set_time_limit(time_limit);
}
}
Expand Down

0 comments on commit 314a8b5

Please sign in to comment.