eudrino
eudrino
SSolidJS
Created by oneiro on 11/10/2023 in #support
Set headers inside createServerAction$()
also, if the intended goal is to send json, it's suggested to use the json function from solid-start, using it will simplify the code above to:
const resp = json(result);
return resp;
const resp = json(result);
return resp;
3 replies
SSolidJS
Created by oneiro on 11/10/2023 in #support
Set headers inside createServerAction$()
I believe responseHeaders is read-only here, not sure but using Response should work
const resp = new Response(JSON.stringify(result), { headers: { 'Content-Type': "application/json; charset=utf-8" }});
const resp = new Response(JSON.stringify(result), { headers: { 'Content-Type': "application/json; charset=utf-8" }});
3 replies
SSolidJS
Created by eudrino on 11/9/2023 in #support
Cache dom elements with router
moving the creation of node to App seems to fix the routing issue, thanks!
const channels = [
{
name: "support",
type: "text",
},
{
name: "general",
type: "text",
},
{
name: "community",
type: "text",
},
{
name: "showcase",
type: "text",
},
{
name: "off-topic",
type: "text",
},
];

const App = () => {
const channelElements = channels.map((channel, i) => ({
node: (
<div>
<span>{channel.type}</span>
<span>{channel.name}</span>
<A href={channels[i + 1]?.name ?? ""}>{channels[i + 1]?.name}</A>
</div>
),
name: channel.name,
}));
return (
<Routes>
<Route
path="/:channel"
component={() => {
const params = useParams();
return (
<div>
{channelElements.find((c) => c.name == params.channel)!.node}
</div>
);
}}
/>
</Routes>
);
};
render(
() => (
<Router>
<App />
</Router>
),
root!
);
const channels = [
{
name: "support",
type: "text",
},
{
name: "general",
type: "text",
},
{
name: "community",
type: "text",
},
{
name: "showcase",
type: "text",
},
{
name: "off-topic",
type: "text",
},
];

const App = () => {
const channelElements = channels.map((channel, i) => ({
node: (
<div>
<span>{channel.type}</span>
<span>{channel.name}</span>
<A href={channels[i + 1]?.name ?? ""}>{channels[i + 1]?.name}</A>
</div>
),
name: channel.name,
}));
return (
<Routes>
<Route
path="/:channel"
component={() => {
const params = useParams();
return (
<div>
{channelElements.find((c) => c.name == params.channel)!.node}
</div>
);
}}
/>
</Routes>
);
};
render(
() => (
<Router>
<App />
</Router>
),
root!
);
7 replies
SSolidJS
Created by eudrino on 11/9/2023 in #support
Cache dom elements with router
well, there might be other optimizations that could be done first ultimately i want to leave those nodes around and re-use them it might harm the memory usage of my app, but it'll be way smoother to change between views each view consists of up to 5k nodes (i might work on lowering these, but it won't be much lower)
7 replies
SSolidJS
Created by eudrino on 11/9/2023 in #support
Cache dom elements with router
Well, i'm trying to optimize the element swap computation, currently it requires cloning the template for a huge component, which takes considerably longer on slower devices compared to just creating those nodes before hand and then calling node.replaceWith
7 replies
SSolidJS
Created by eudrino on 4/9/2023 in #support
DOM nodes caching for faster swap
Have a good day!
4 replies
SSolidJS
Created by eudrino on 4/9/2023 in #support
DOM nodes caching for faster swap
Thank you for the help, all the potential issues you pointed out seem to be fine for my use case.
4 replies