-
When using IDOM 0.32.0 I'm getting the following error in the browser console:
This error text is from the Firefox console. Chrome also produces a similar error. I've included the code I'm using below. Background: I'm using IDOM to experiment with linguistics-related software, specifically new approaches for working with parallel corpuses -- source and translated works, side by side, or in this case, on top of one another. There are two panes ( How to reproduce the error: In the top pane, continue clicking the "Next" button. After initial load, whenever the sentence id reaches 3, the next click of "Next" always produces the error. The client side fails to update, but the server-side state ( At this point, clicking the "Next" button in the bottom pane causes the interface to update. Continuing to move back and forth in the upper pane, its text becomes mangled. import idom
import random
@idom.component
def RangeWords(text):
highlight_range, set_highlight_range = idom.hooks.use_state([])
def update_range(index):
if highlight_range == []:
set_highlight_range([index])
elif highlight_range == [index]:
set_highlight_range([])
elif index in [highlight_range[-1], highlight_range[0]]:
set_highlight_range([index])
elif index < highlight_range[0]:
set_highlight_range(list(range(index, highlight_range[0] + 1)))
else:
set_highlight_range(list(range(highlight_range[0], index + 1)))
divs = [
idom.html.div({
'onClick': lambda e, i=i: update_range(i),
'style': {
'backgroundColor': 'aquamarine' if i in highlight_range else 'white',
'display':'inline',
'padding':'5px'
}
},
word,
key=str(random.random())
)
for i,word in enumerate(text.split())
]
return idom.html.div({
'style': {
'width':'95%',
'display':'flex',
'flex-wrap':'wrap',
'margin':'5px'}
},
divs
)
@idom.component
def WorkSentDiv(tfname):
sid, set_sid = idom.hooks.use_state(0)
works = {'bubs': ["it was the best of times, it was the blurst of times.",
"they will break upon this fortress like water on rock.",
"ah those heady days of yore.",
"forge ahead, no matter the cost.",
"bring me the head of alfredo garcia.",
"there were monsters aboard that ship, and truly we were them."],
'zugzug': ["나도너도나도 웰웰웰 아하아하.",
"섬웨어 오버 더 레인보.",
"유 캔트 듀 댓 온 테레비즌.",
"컴퓨터 프로그램잉.",
"어메이징 테일즈.",
"대츠 오케이!",
"데르즈 노 비지니스 라이크 쇼 비지니스"]}
def get_stext(tfname, sid):
if sid < len(works[tfname]):
return works[tfname][sid]
else:
return "no more sentences"
def btn_click(count):
if sid + count < 0:
return
set_sid(sid + count)
return idom.html.div(
idom.html.div(f"sentence id: {sid}"),
idom.html.button({'onClick': lambda e:btn_click(-1)}, "Prev"),
idom.html.button({'onClick': lambda e:btn_click(1)}, "Next"),
RangeWords(get_stext(tfname, sid))
)
@idom.component
def DualWorkView():
return idom.html.div(
WorkSentDiv("bubs"),
WorkSentDiv("zugzug")
)
idom.run(DualWorkView) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Was able to reproduce. Tracking here: #489 |
Beta Was this translation helpful? Give feedback.
Was able to reproduce. Tracking here: #489