vikash
Console.log inside createEffect not printing...Even the setUser was called.
import { createEffect, createSignal, onMount } from "solid-js";
import { useSession } from "vinxi/http";
function getSession() {
return useSession({
password:
"my_secret_password_sajklhjkaojhjsdflkhasjdlfhsjkdfhajshflkjasdhfjalsdjfhlasjdhfjklashdfjsaflaskjfhsdflajhj",
});
}
const getUser = async () => {
const session = await getSession();
return session.data;
};
export default function Chat() {
const [user, setUser] = createSignal(null);
getUser().then((data) => {
setUser(data);
console.log("data : ", data);
console.log("user() : ", user());
});
createEffect(() => {
console.log("user : ", user());
});
return (
<main>
<h1>Chat</h1>
</main>
);
}
import { createEffect, createSignal, onMount } from "solid-js";
import { useSession } from "vinxi/http";
function getSession() {
return useSession({
password:
"my_secret_password_sajklhjkaojhjsdflkhasjdlfhsjkdfhajshflkjasdhfjalsdjfhlasjdhfjklashdfjsaflaskjfhsdflajhj",
});
}
const getUser = async () => {
const session = await getSession();
return session.data;
};
export default function Chat() {
const [user, setUser] = createSignal(null);
getUser().then((data) => {
setUser(data);
console.log("data : ", data);
console.log("user() : ", user());
});
createEffect(() => {
console.log("user : ", user());
});
return (
<main>
<h1>Chat</h1>
</main>
);
}
3 replies