Closed luoweb closed 1 year ago
Sorry this issue is very unclear and the code that is provided is not formatted correctly. Please edit the issue to fix this.
Sorry this issue is very unclear and the code that is provided is not formatted correctly. Please edit the issue to fix this.
had formatted. It seems that the component did not await before return. here is another reproduction code:
import gradio as gr
GetLocalStorage = """
function() {
// debugger;
console.log("GetLocalStorage");
globalThis.setStorage = (key, value)=>{
console.log("setStorage:" + key);
localStorage.setItem(key, value);
};
globalThis.getStorage = (key)=>{
console.log("getStorage:" + key);
return localStorage.getItem(key);
};
# did not return timeout = 7
setTimeout("localStorage.setItem('timeout','7')",5000 );
const localstorage = JSON.stringify(localStorage);
console.log("localstorage:" + localstorage);
return [localstorage]
}
"""
with gr.Blocks() as demo:
with gr.Column(variant="panel", elem_id="txt2imgPanel"):
with gr.Row(variant="compact"):
url_params = gr.JSON({"key":"value"}, visible=True, label="URL Params")
text_input = gr.Text(label="Input")
text_output = gr.Text(label="Output")
demo.load(None,None,[text_output],_js=app_jslib.GetLocalStorage)
[localstorage] return old value, setTimeout("localStorage.setItem('timeout','7')",5000 );
code mistake that js function not sync
Describe the bug
JS call txt or image not update, like the bug:Fix JS call #4486, the different is as flow:
Have you searched existing issues? 🔎
Reproduction
UI:
_JS:
Screenshot
![Uploading image.png…]() ![Uploading Screenshot 2023-08-09 at 9.21.24 AM.png…]()
Logs
System Info
Severity
I can work around it