S
SolidJS3mo ago
Eve

unwrap doesn't seem to do anything

I'm trying to get a plain object, because seroval chokes at trying to serialize a store directly. But unwrap still returns a proxy.
function App() {
const [people, setPeople] = createStore<any[]>([]);
createEffect(() => {
const ppl = unwrap(people);
console.log('store: ', people)
console.log('unwrap: ',ppl)
console.log('JSON: ', JSON.parse(JSON.stringify(people)));
})
return (<></>);
}
function App() {
const [people, setPeople] = createStore<any[]>([]);
createEffect(() => {
const ppl = unwrap(people);
console.log('store: ', people)
console.log('unwrap: ',ppl)
console.log('JSON: ', JSON.parse(JSON.stringify(people)));
})
return (<></>);
}
https://playground.solidjs.com/anonymous/351edceb-6107-4f57-81fa-6e2363ed1bf3
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
No description
4 Replies
REEEEE
REEEEE3mo ago
It's not proxied, it just has the symbols on it Does seroval still throw an error with the unwrapped object?
Alex Lohr
Alex Lohr3mo ago
If you add something to the store it should become obvious.
JP
JP3mo ago
const ppl = unwrap(people);
setPeople([10])
console.log('store: ', people)
console.log('unwrap: ',ppl)
const ppl = unwrap(people);
setPeople([10])
console.log('store: ', people)
console.log('unwrap: ',ppl)
I expected ppl to be [], but in the console it shows as [10] I'm totally new to solid BTW. After reading the unwrap documentation, I realized I need to understand Solid concepts much more thoroughly. If someone here could provide guidance on materials I can read to gain a better understanding, it would be greatly appreciated. I've already read the documentation and watched all of Ryan's videos and articles that I could find.
Alex Lohr
Alex Lohr3mo ago
Chrome console conveniently formats things that look like an array as arrays.
Want results from more Discord servers?
Add your server