瀏覽代碼

Fix frontend event infinite loop (#1207)

Nikhil Rao 1 年之前
父節點
當前提交
b37560cbeb
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      pynecone/.templates/web/utils/state.js

+ 2 - 2
pynecone/.templates/web/utils/state.js

@@ -166,10 +166,10 @@ export const processEvent = async (
   setResult({ ...result, processing: true });
 
   // Apply the next event in the queue.
-  const event = state.events[0];
+  const event = state.events.shift();
 
   // Set new events to avoid reprocessing the same event.
-  setState(state => ({ ...state, events: state.events.slice(1) }));
+  setState(state => ({ ...state, events: state.events }));
 
   // Process events with handlers via REST and all others via websockets.
   let eventSent = false;