goe1980
goe1980
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
Thank you for the enlightenment guys!
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
ok, now I see it, ty 👍
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
No description
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
hummm, I'm not seeing the props as getters on the playground... IDK
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
My doubt is that, if you're calling "optionsResource()" it will be a value not a signal, what am I missing here?
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
<Suspense>
<MyComponent options={optionsResource()}/>
</Suspense>
<Suspense>
<MyComponent options={optionsResource()}/>
</Suspense>
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
But you're calling it
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
No, I mean your review
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
Just one thing. If you use optionsResource() as a prop, what's the problem on destructuring it inside the component? It's just a value, it will make no harm to the solid reactive system, right?
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
Ty for the review
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
function MyComponent(props) {
const options = props.optionsResource
const [focused, setFocus] = createSignal(false)

const opened = createMemo(() => !!options() && options().length > 0 && focused())

return (
<div>
<input onBlur={() => setFocus(false)} onFocus={() => setFocus(true)} />
<div class={setClassesWhen('list', opened, 'is-open is-focused')} role="listbox">
<For each={options()}>{(value, idx) => <div data-id={idx()}>{value}</div>}</For>
</div>
</div>
)
}
function MyComponent(props) {
const options = props.optionsResource
const [focused, setFocus] = createSignal(false)

const opened = createMemo(() => !!options() && options().length > 0 && focused())

return (
<div>
<input onBlur={() => setFocus(false)} onFocus={() => setFocus(true)} />
<div class={setClassesWhen('list', opened, 'is-open is-focused')} role="listbox">
<For each={options()}>{(value, idx) => <div data-id={idx()}>{value}</div>}</For>
</div>
</div>
)
}
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
I'll share my solution, in the hope to help someone rethinking their signal dependencies.
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
After a few attempt to re-wire things I came up with a cleaner solution and avoid using createEffect.
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
Thank you all for your help. I guess I'll use createEffect carefully trying to avoid any circular references.
39 replies
SSolidJS
Created by goe1980 on 2/8/2024 in #support
Is there any secure alternative to createEffect?
Thank you for your suggestion, but in that case I'll not have a setter for "open" because it is a derived value from the options signal (which is made with createResource). I need the setter so I can use it on other events like input focus and blur.Don't know if I'm doing this right, but that's how I see the problem.
39 replies