[solved] Brain fart: in need of fresh eyes

I just can't seem to access the results outside of the function in my returned jsx. Hoping to loop and create <option value={item.id}>{item.name}</option> Thank you in advance.
10 Replies
dmayo2
dmayo2OP2y ago
dmayo2
dmayo2OP2y ago
this works just fine, and I can't see the difference between getData and fetchZones. Going to lunch. <ugh>
REEEEE
REEEEE2y ago
allTimeZones() Not allTimeZones Also it should be a map not a foreach
dmayo2
dmayo2OP2y ago
down in the returned jsx -- tried that and it never Shows Thought I tried the map. I'll go back. thanks.
REEEEE
REEEEE2y ago
map((item) => <option...) or map((item) => { return <option...})
dmayo2
dmayo2OP2y ago
with the () the show never fires. When I take the () away, then it "Shows" but then get error in console allTimeZones() is undefined -- which makes sense if the <Show fires right away rather than waiting for the <Show when={allTimeZones()}> accutually should "show" --- I'm going in circles. Thanks for looking, I'm just going to delete and start over.
REEEEE
REEEEE2y ago
What about allTimeZones()?.allzones In the show Sorry in the map call allTimeZones()?.allzones.data.map I did not realize but your map in that screenshot will not work because it isn't returning anything.
<Show when={allTimeZones()}>
<select>
{allTimeZones()?.allzones.data.map((item) => <option> {item.name} </option>)
</select>
</Show>
<Show when={allTimeZones()}>
<select>
{allTimeZones()?.allzones.data.map((item) => <option> {item.name} </option>)
</select>
</Show>
dmayo2
dmayo2OP2y ago
I just can't seem to get the data outside of the fetchZones arrow function. So, however incorrect the JSX may be, I'm not making it available outside the arrow function. Deleting...
REEEEE
REEEEE2y ago
if you console log allTimeZones in a createEffect what does it output?
createEffect(() => {
console.log(allTimeZones())
})
createEffect(() => {
console.log(allTimeZones())
})
dmayo2
dmayo2OP2y ago
Thanks for helping me think through the issue. It was something not getting it out of the function correct, thus the JSX wasn't the issue. Now, I'm not exactly sure which is the correct way, but I'm not touching this damn thing (for a bit anyway).
Want results from more Discord servers?
Add your server