Open ltfschoen opened 1 year ago
Yeah, that's stretching the limits of what auto_branch
can do atm, the control flow analysis is pretty dumb because I don't want to pull in syn
and kill compile times. It's fixable, but for now you might have to disable auto_branch
and wrap the view!
invocations in appropriate BranchN enum.
Yeah, that's stretching the limits of what
auto_branch
can do atm, the control flow analysis is pretty dumb because I don't want to pull insyn
and kill compile times. It's fixable, but for now you might have to disableauto_branch
and wrap theview!
invocations in appropriate BranchN enum.
Thanks, I got it to work with Branch3
...
use kobold::branching::Branch3;
...
#[component]
fn Cell(col: usize, row: usize, state: &Hook<State>) -> impl View + '_ {
let value = state.source.get_text(&state.rows[row][col]);
if state.editing == (Editing::Cell { row, col }) {
let onchange = state.bind(move |state, e: Event<InputElement>| {
state.rows[row][col] = Text::Owned(e.target().value().into());
state.editing = Editing::None;
});
Branch3::A(view! {
<td.edit>
{ ref value }
<input.edit {onchange} value={ ref value } />
</td>
})
// https://github.com/maciejhirsz/kobold/issues/51
} else {
let ondblclick = state.bind(move |s, _| s.editing = Editing::Cell { row, col });
if value.contains("0x") {
Branch3::B(view! {
<td {ondblclick}>
{ ref value }
<QRForTask {value} />
</td>
})
} else {
Branch3::C(view! {
<td {ondblclick}>{ ref value }</td>
})
}
}
}
I can get it to render if i do a single level of
if
,else if
, andelse
statementsBut if i use the code that has been commented out instead, which seems to be the same code, but so i have just nested
if
else
statements, then it gives the following error. is the idea that i should proceed trying to figure out how to use Box::new if i want to use nestedif
else
statements?