mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-11 11:19:58 +08:00
fix: make sure comp.instance
exists (#10207)
* fix: make sure `comp.instance` exists * add changeset * fix: update syntax --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
13a83e5001
commit
314a8b55f5
6
.changeset/wild-chicken-pay.md
Normal file
6
.changeset/wild-chicken-pay.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/core": patch
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:fix: make sure `comp.instance` exists
|
@ -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;
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user