Comments (2)
Steps I took to debug:
- Saw that this was a keyed list, and that the issue was solved by fixing the keys. Wondered whether there could be duplicated keys.
- In
<BadTable/>
, I added an effect to log out the keys:
create_effect(move |_| {
leptos::logging::log!(
"{:?}",
rows().into_iter().map(|tuple| tuple.0).collect::<Vec<_>>()
);
});
- Saw that this logs twice when I resize. This is because you update two separate signals in the event handler, and read from both of those signals in the
let rows
definition. In Leptos 0.6 and earlier, signal updates/effects are not batched by default but run synchronously — so the rows are basically updated twice when you click, one for each signal they depend on. Note thatrows
reads from the grid signal, but the keys don't depend on the grid signal (unlike in GoodTable), so an "old" row sticks around. - I added
batch(move || { ... })
inside theresize
function:
let resize = move |dim: Dimensions| {
batch(move || {
set_dimensions.update(|dimensions| *dimensions = dim); // this can be .set() btw
let mut new_vec = vec![];
for _ in 0..dimensions.with(|d| d.width * d.height) {
new_vec.push(create_signal(Cell { example: false }));
}
set_grid.update(|grid| *grid = new_vec); // this can be .set() btw
});
};
Works as expected.
Broader point: There's no reason to use <For/>
here, as you are invalidating every key on every dimension change anyway, so all of them will be replaced when the dimensions change. If you use plain iteration it will perform exactly the same and you won't have the key or batching issue.
from leptos.
Thanks so much!
from leptos.
Related Issues (20)
- 0.7-beta Resource isnt updated with source signal HOT 3
- LocalResource spawn_local called from outside of a task::LocalSet HOT 2
- `0.7-beta` Router `A` component missing `class` & `active_class` props HOT 5
- Path Params not begin passed to nested routes in 0.7 HOT 1
- `0.7-beta` Deeply nested `ParentRoute` does not work with relative routing
- Suspend wrapped LocalResource panics
- True async - Fix or Educate HOT 2
- `0.7-beta` Missing `serde` when using `experimental-islands` and custom props HOT 1
- `0.7-beta` Panic when trying to render nested `island` HOT 4
- `0.7-beta` Nesting an island inside another island's body hydrates the inner island twice HOT 2
- Bump MSRV to 1.8, so we can drop lazy_static
- `0.7-beta` Panic when passing props to `island`
- `0.7-beta` Panic when using `LocalResource` in `island`
- `0.7-beta` Rendering `island` inside `<Suspense>` does not work
- .leptos_routes() server fn routing should respect excluded routes
- Never resolve Futures synchronously to prevent class of errors HOT 2
- Nesting ErrorBoundary in Suspense panics on hydration HOT 1
- `0.7-beta` `ServerAction` panics when being dispatched in effect
- `0.7-beta` Panic when `ServerAction` value in `Effect` unmounts HOT 1
- Extracting body information from request does not work. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leptos.