navi.ToTskie
navi.ToTskie
SSolidJS
Created by navi.ToTskie on 12/16/2023 in #support
When to use data.loading vs <suspense>
tsx
{data.loading? <h1>...loading</h1>:<MyComponent data={current} />}
tsx
{data.loading? <h1>...loading</h1>:<MyComponent data={current} />}
looks cleaner. ahh okay, thanks. i think i understand
5 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
official website createresource
No description
3 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
official website createresource
import { createResource, createSignal, Suspense } from "solid-js";
import { useParams } from "@solidjs/router";
// :point_down: This is an asynchronous function that fetches a user from the jsonplaceholder API
async function fetchUser(id) {
const response = await fetch(`https://jsonplaceholder.typicode.com/users/${id}`);
return response.json();
}
const User = () => {
const params = useParams();
const [data] = createResource(params.id,fetchUser) // :point_left: Pass the dynamic route parameter to the createResource primitive
return (
<Suspense fallback={<p>Loading...</p>}>
<div>
<p>Name: {data().name}</p> {/* :point_left: Access the data returned from the fetchUser function */}
<p>Email: {data().email}</p>
<p>Phone: {data().phone}</p>
</div>
</Suspense>
);
};
export default User;
import { createResource, createSignal, Suspense } from "solid-js";
import { useParams } from "@solidjs/router";
// :point_down: This is an asynchronous function that fetches a user from the jsonplaceholder API
async function fetchUser(id) {
const response = await fetch(`https://jsonplaceholder.typicode.com/users/${id}`);
return response.json();
}
const User = () => {
const params = useParams();
const [data] = createResource(params.id,fetchUser) // :point_left: Pass the dynamic route parameter to the createResource primitive
return (
<Suspense fallback={<p>Loading...</p>}>
<div>
<p>Name: {data().name}</p> {/* :point_left: Access the data returned from the fetchUser function */}
<p>Email: {data().email}</p>
<p>Phone: {data().phone}</p>
</div>
</Suspense>
);
};
export default User;
3 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
nvm thanks 😄
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
const [data,{refetch}] = createResource(params.id,thisProject)
refetch()
const [data,{refetch}] = createResource(params.id,thisProject)
refetch()
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
createeffect does the same thing as
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
i can solve it like this but it looks like redundant
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
do you have this kind of error on createresource?
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
same error 😦
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
awp
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
anyways that is the code where it might configure it wrong?
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
yeah i always wanted to learn this before like coloring the code on discord
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
export default function inProj(){
const params = useParams();
const [data] = createResource(params.id,thisProject)

return (

<CredentialUser>
<Body>
<main class="mt-5 pt-3">
<div class="container-fluid">

<Suspense fallback={<p>..loading</p>}>
<div>
<p>Name: {data()[0].name}</p>

</div>
</Suspense>


</div>
</main>

</Body>
</CredentialUser>
);
}
export default function inProj(){
const params = useParams();
const [data] = createResource(params.id,thisProject)

return (

<CredentialUser>
<Body>
<main class="mt-5 pt-3">
<div class="container-fluid">

<Suspense fallback={<p>..loading</p>}>
<div>
<p>Name: {data()[0].name}</p>

</div>
</Suspense>


</div>
</main>

</Body>
</CredentialUser>
);
}
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
thanks for i learn new on discord hahaha
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
shttt hahaha
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
ahhh
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
async function thisProject(id) {

const response = await fetch(
`${import.meta.env.VITE_API_ENDPOINT}/getIdProject`,{
method: 'POST',
body: JSON.stringify({
id:parseInt(id)
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})

return await response.json();
}
async function thisProject(id) {

const response = await fetch(
`${import.meta.env.VITE_API_ENDPOINT}/getIdProject`,{
method: 'POST',
body: JSON.stringify({
id:parseInt(id)
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})

return await response.json();
}
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
how to new line here?
48 replies
SSolidJS
Created by navi.ToTskie on 12/12/2023 in #support
createresource why is this error even on a basic example
here is the whole code
48 replies