Possible to map of `useSubmissions` result?

I was just playing with solid-router, and was curious if there was a way to map over the results of useSubmissions outside of a rendered <For> component. In the linked code: https://github.com/JacobSNGoodwin/scavenge-solid/blob/main/src/components/HuntItemsList.tsx#L43, I was trying to basically create a list of items where I optimistically filtered out any items being deleted and optimistically added any being added, while also sorting them. I was able to get the ids of submissions being deleted in a good old fashioned for loop, but we cannot map over the Proxied array (which may be fine and desirable). So this had me wondering if anyone has opinions on the best way to handle this sort of situation. I'm probably coming from the react world and not doing this right.
GitHub
scavenge-solid/src/components/HuntItemsList.tsx at main · JacobSNGo...
A playground for managing scavenger hunts build with solid-start > 0.4 - JacobSNGoodwin/scavenge-solid
3 Replies
peerreynders
peerreynders4mo ago
If pressed you can always use the $TRACK symbol (exported by solid-js) to gain access to the core array (with reactivity only to the array as a whole):
const raw = (s: SetCountSubmissionMany) => {
if($TRACK in s) {
return s[$TRACK] as SetCountSubmissionMany;
}
throw new Error('Not a solid.js Proxy')
}
const raw = (s: SetCountSubmissionMany) => {
if($TRACK in s) {
return s[$TRACK] as SetCountSubmissionMany;
}
throw new Error('Not a solid.js Proxy')
}
https://stackblitz.com/edit/solidjs-templates-7u2yad?file=src%2Fapp.tsx Though I'm not sure whether that constitutes __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED usage. https://github.com/solidjs/solid-router/blob/bf255e3abe2102ca127a8f53664071c5161878ae/src/data/action.ts#L31
peerreynders
StackBlitz
solid.js action cache interplay - StackBlitz
A Solid TypeScript project based on @solidjs/router, solid-js, typescript, vite and vite-plugin-solid
GitHub
solid-router/src/data/action.ts at bf255e3abe2102ca127a8f53664071c5...
A universal router for Solid inspired by Ember and React Router - solidjs/solid-router
brenelz
brenelz4mo ago
You can do something like this I think. [...submissions.values()].map
jacobgoodwin
jacobgoodwin4mo ago
Thanks. It will be useful for me to look into the internals to better understand solid-js. This does work! Thanks. I guess this is a way to access the inner array of the proxy, then. This is one I'll definitely want to catelog in the old noggin'
Want results from more Discord servers?
Add your server
More Posts
Help Me Understand SolidStart vs. Next.js CachingI'm new to meta frameworks like SolidStart and I'm learning about Next.js to understand them better.Understanding Solid Reactivity Lint ErrorIn the following component I get this lint warning: ``` The reactive variable 'handleContextMenuCommExample in solid-testing-library example not workingHello, the `can render a route with the id` test in the solid-testing-library https://github.com/sol"<A> and 'use' router primitives can be only used inside a Route." When testing component in routerI receieve this error when trying to test a component. The component is inside another component thaFailed to execute 'replaceChild' on 'Node': The node to be replaced is not a child of this node.I have a store: ```typescript export const [mainStore, setMainStore] = createStore<StoreType>({ couSet default location stateHi, I'm trying to have a default state object for all navigation using solid router. I tried using uWhy does adding a new field duplicate the value?https://stackblitz.com/edit/github-zon5da?file=src%2FApp.tsx When entering a value in the input fiDoes SolidStart have a function like basePath of nextjs?I want to deploy SolidStart to a domain subpath. https://nextjs.org/docs/app/api-reference/next-confDependency configuration in AstroI'm trying to add `solid-bootstrap` as a dependency in an Astro + Solid project. This results in theHow do I postpone invocation of fetcher function of the solid-js resource?I have following snippet in my .tsx file. Could you please explain why mappings resource is being ca