pronoob
pronoob
Explore posts from servers
SSolidJS
Created by pronoob on 3/3/2024 in #support
I have to fetch initial information in a component, how do I do it?
const App: Component = () => { const resp = await fetch(...); // show Home component after fetch is completed }
2 replies
SSolidJS
Created by pronoob on 3/3/2024 in #support
How do I "protect" routes? I am using @solidjs/router
Now that Outlet is not supported anymore? How do I implement a route guard for nested routes?
3 replies
SSolidJS
Created by pronoob on 11/10/2023 in #support
How do I implement authentication?
Hey there! I want to implement a very authentication, how would I go about implementing it? The user visits /register to create a new account. After they have created a new account, they must authentication by successfully logging in usingthe /login, at this point, they should be able to see the content of the /proc route
18 replies
SSolidJS
Created by pronoob on 8/27/2023 in #support
How to save canvas state to backend and load it later?
How can I load the state and save it to the backend later?
4 replies
SSolidJS
Created by pronoob on 7/6/2023 in #support
How can I stop code from executing before?
I am using @solidjs/router for routing, here's the code:
<Router>
<Routes>
<Route path="/" component={Guard}>
<Route path="/" component={Root} />
</Route>

<Route path="/login" component={Login} />
</Routes>
</Router>
<Router>
<Routes>
<Route path="/" component={Guard}>
<Route path="/" component={Root} />
</Route>

<Route path="/login" component={Login} />
</Routes>
</Router>
The Guard component checks for authentication (whether key is not in localStorage) in createEffect and navigates based on the result. The Root component is a protected component and only authenticated user can access it (localStorage contains the key item). The Root component looks something like this:
const Root: Component = () => {
const ws = new WebSocket("...");
ws.onmessage = e => {
console.log(e);
};

return <h1>Root</h1>;
};
const Root: Component = () => {
const ws = new WebSocket("...");
ws.onmessage = e => {
console.log(e);
};

return <h1>Root</h1>;
};
However, the WebSocket is connected before the Guard component validates and navigates the user.
5 replies
SSolidJS
Created by pronoob on 7/3/2023 in #support
How to have a default layout for all routes?
I am using @solidjs/router and I want to have a default layout to have a default background color. How do I do that?
46 replies
SSolidJS
Created by pronoob on 6/26/2023 in #support
How to define reference for a component?
How can I define ref for a custom component with TypeScript?
18 replies