SomeRandomNiko
SomeRandomNiko
SSolidJS
Created by SomeRandomNiko on 6/17/2024 in #support
Reactivity issues with array items
Ok that makes sense thank you! As for checking if the waypoint order or the waypoints themselves change i "hash" their coordinates and compare that to the previous hash in the effect and it seems to work. I don't know if that is an ideal solution though
createEffect<string>((prevHash) => {
const wp = waypoints();
const hash = wp.map((wp) => wp.lngLat.join(",")).join("|");
if (prevHash !== hash) {
batch(() => {
if (wp.length >= 2) {
debouncedFetchRoute(wp);
}
setTransferForm("route", null);
});
}
return hash;
});
createEffect<string>((prevHash) => {
const wp = waypoints();
const hash = wp.map((wp) => wp.lngLat.join(",")).join("|");
if (prevHash !== hash) {
batch(() => {
if (wp.length >= 2) {
debouncedFetchRoute(wp);
}
setTransferForm("route", null);
});
}
return hash;
});
10 replies
SSolidJS
Created by SomeRandomNiko on 6/17/2024 in #support
Reactivity issues with array items
like this?
const containersWithWaypoints = () =>
transferForm.waypoints.containerContents.filter((container) =>
untrack(() => container.waypoint) !== null,
);

const waypoints = () => containersWithWaypoints().map((c) => untrack(() => c.waypoint)!);
const containersWithWaypoints = () =>
transferForm.waypoints.containerContents.filter((container) =>
untrack(() => container.waypoint) !== null,
);

const waypoints = () => containersWithWaypoints().map((c) => untrack(() => c.waypoint)!);
Still behaves the same way
10 replies
SSolidJS
Created by SomeRandomNiko on 6/17/2024 in #support
Reactivity issues with array items
No description
10 replies