alrightsure
alrightsure
Explore posts from servers
SSolidJS
Created by alrightsure on 9/5/2024 in #support
Top level "use server" doesn't seem to work
Hey all, I've noticed that I put "use server" at the top of the file, it doesn't seem to actually treat the functions in the file as server functions, and the actions don't work as expected. I wanted to ask here before filing an issue, as I feel like maybe I am misunderstanding. For example, this seems to work:
import { db } from "./db";
import { action, cache, revalidate } from "@solidjs/router";

export const getMessages = cache(async () => {
"use server";

const messages = await db.messages.findMany();
return messages;

}, "messages");

export const sendMessage = action(async ({ text }: { text: string }) => {
"use server";

await db.messages.create({
data: { text }
});

revalidate(getMessages.keyFor());
});
import { db } from "./db";
import { action, cache, revalidate } from "@solidjs/router";

export const getMessages = cache(async () => {
"use server";

const messages = await db.messages.findMany();
return messages;

}, "messages");

export const sendMessage = action(async ({ text }: { text: string }) => {
"use server";

await db.messages.create({
data: { text }
});

revalidate(getMessages.keyFor());
});
However, this throws an error when I try to call these functions:
"use server";

import { db } from "./db";
import { action, cache, revalidate } from "@solidjs/router";

export const getMessages = cache(async () => {
const messages = await db.messages.findMany();
return messages;

}, "messages");

export const sendMessage = action(async ({ text }: { text: string }) => {
await db.messages.create({
data: { text }
});

revalidate(getMessages.keyFor());
});
"use server";

import { db } from "./db";
import { action, cache, revalidate } from "@solidjs/router";

export const getMessages = cache(async () => {
const messages = await db.messages.findMany();
return messages;

}, "messages");

export const sendMessage = action(async ({ text }: { text: string }) => {
await db.messages.create({
data: { text }
});

revalidate(getMessages.keyFor());
});
Is this intended behavior?
6 replies
SSolidJS
Created by alrightsure on 5/18/2023 in #support
useRouteData empty on HMR
I'm just curious about the expected behavior of useRouteData in Solid Start. It seems to return an empty response after HMR, but only in certain situations. I created two identical pages with different route data functions. One pulls from the Pokemon API and another accesses my firestore instance:
export const routeData = () => {
return createServerData$(async () => {
const resp = await fetch("https://pokeapi.co/api/v2/pokemon/ditto");
return await resp.json();
});
};
export const routeData = () => {
return createServerData$(async () => {
const resp = await fetch("https://pokeapi.co/api/v2/pokemon/ditto");
return await resp.json();
});
};
export const routeData = () => {
return createServerData$(async () => {
const exercisesSnapshot = await db.exercises.get();
return exercisesSnapshot.docs.map(doc => ({ id: doc.id, ...doc.data() }));
});
};
export const routeData = () => {
return createServerData$(async () => {
const exercisesSnapshot = await db.exercises.get();
return exercisesSnapshot.docs.map(doc => ({ id: doc.id, ...doc.data() }));
});
};
The Pokemon page seems to persist data through HMRs, however, my route data from firestore seems to be empty after an HMR. Does anyone have any insight into this?
3 replies
TTCTheo's Typesafe Cult
Created by alrightsure on 5/12/2023 in #questions
Suggestions for React Native offline-first DB with syncing
Hi all, basically I’m trying to get Firebase functionality without using Firebase. because of Their Typescript support is pretty bad and I would rather use something like Supabase on the backend. Things I’ve considered: - Realm: Not bad, would prefer to use a SQL backend - WatermelonDB: also flakey TS support and can’t get it to build with Expo - RXDB: seems cool, but the only option that seems to actually support React Native out of the box is locked behind a pricey subscription - Replicache: very expensive - Redux Persist: seems like it would do the job but not as performant as some other options with a lot of boilerplate. Does anyone have any other suggestions?
6 replies
SSolidJS
Created by alrightsure on 1/27/2023 in #support
Calling database with server actions in Solid Start
Hey all, I have a question more about best practices than anything. In the Solid Start docs, under the Server Actions heading, it says the following:
Or even connecting directly to a database. (Take caution, opinions on if this is a good idea are mixed. You should consider separating your backend and frontend).
Or even connecting directly to a database. (Take caution, opinions on if this is a good idea are mixed. You should consider separating your backend and frontend).
My question is why this may be considered a bad idea, especially when it's not frowned upon in createServerData$.
8 replies
TTCTheo's Typesafe Cult
Created by alrightsure on 11/11/2022 in #questions
Best Practices When Using Components with Tailwind
15 replies
TTCTheo's Typesafe Cult
Created by alrightsure on 10/10/2022 in #questions
Supabase Magic Link Auth with Expo
Anyone ever successfully get this working? I get all of the necessary tokens back with the callback url but I'm not really sure what I should be doing with them. From what I can gather from the documentation (which isn't great) supabase.auth.onAuthStateChange should be firing but it's not.
1 replies