Khyonn
Khyonn
SSolidJS
Created by Khyonn on 7/3/2023 in #support
Is there some cases where createResource doesn't handle errors ?
Yeah, the api.get handles 404 as error Ok, I see, so the best way to make sure everything's fine should be to check if there's an error before evalutating resource() (and in case of error, don't evaluate resource()) ! Checking ... And ... yes, works as expected ! Always love you answers @lexlohr
3 replies
SSolidJS
Created by 100kΩ 11kW Resistor on 6/22/2023 in #support
How to set a url for the Solid router on backend (SSR) side?
If you want to do some SSR, you should probably take a look at https://start.solidjs.com/
9 replies
SSolidJS
Created by Tur on 6/22/2023 in #support
Maximum call stack size exceeded while using createEffect
... well, it's an other way to do this ... but you should probably check out at derived signals like @eslachance said. Because, I don't think it's a good practice to edit an API data directly
14 replies
SSolidJS
Created by Tur on 6/22/2023 in #support
Maximum call stack size exceeded while using createEffect
since you read formValues in a createEffect, il will trigger the effect if it changes... but you change its value in the effect
14 replies
SSolidJS
Created by Tur on 6/22/2023 in #support
Maximum call stack size exceeded while using createEffect
I guess this is because you read and write formValues multiple times
14 replies
SSolidJS
Created by 100kΩ 11kW Resistor on 6/22/2023 in #support
How to set a url for the Solid router on backend (SSR) side?
What do you mean ? Do you want to redirect or you just want to define an API route ?
9 replies
SSolidJS
Created by Khyonn on 6/19/2023 in #support
Troubles Reading / Writing search params using solid-router useSearchParams()
Ok, so the best way to do it currently would be to serialize / deserialize manually like so ?
const serializeParams = (params = {}, joinChar = '|') => {
return Object.fromEntries(Object.entries(params).map(([key, value]) => [key, Array.isArray(value) ? value.join(joinChar) : value]))
}
const deserializeParams = (params = {}, joinChar = '|') => {
return Object.fromEntries(
Object.entries(params)
.map(([key, value]) => [key, value.includes(joinChar) ? value.split(joinChar) : value])
)
)
}

// for an URL like ?plop=a|b or ?plop=a%7Cb
function MyComponent () {
const [searchParams, setSearchParams] = useSearchParams()
console.log(deserializeParams(searchParams).plop) // ['a', 'b']
return (
<button
onClick={() => {
setSearchParams(serializeParams({ pouet: ['a', 'b'] })) // will update params like ?plop=a%7Cb&pouet=a%7Cb
}}>
Update search params
</button>
}
const serializeParams = (params = {}, joinChar = '|') => {
return Object.fromEntries(Object.entries(params).map(([key, value]) => [key, Array.isArray(value) ? value.join(joinChar) : value]))
}
const deserializeParams = (params = {}, joinChar = '|') => {
return Object.fromEntries(
Object.entries(params)
.map(([key, value]) => [key, value.includes(joinChar) ? value.split(joinChar) : value])
)
)
}

// for an URL like ?plop=a|b or ?plop=a%7Cb
function MyComponent () {
const [searchParams, setSearchParams] = useSearchParams()
console.log(deserializeParams(searchParams).plop) // ['a', 'b']
return (
<button
onClick={() => {
setSearchParams(serializeParams({ pouet: ['a', 'b'] })) // will update params like ?plop=a%7Cb&pouet=a%7Cb
}}>
Update search params
</button>
}
6 replies