Gabriel Viol
Gabriel Viol
SSolidJS
Created by Gabriel Viol on 5/13/2024 in #support
Reactivity of my component
Yes, this is my store. To elaborate, I have buttons on the screen. Each button has a value. Clicking a button stores its value in the store as CplId. When this CplId changes, an element corresponding to this CplId needs to be rendered. However, the button isn't within the same component that renders this element. Therefore, I achieve this with the following code:
const [local, rest] = splitProps(store, ['CplId']);
const [ itemActive, setItemActive ] = createSignal();
createEffect(() => {
const items = path(['props', 'children'], element.children[0])
const foundItem = items.find(item => item.props.cplId === local.CplId);
setItemActive(foundItem)
})
const [local, rest] = splitProps(store, ['CplId']);
const [ itemActive, setItemActive ] = createSignal();
createEffect(() => {
const items = path(['props', 'children'], element.children[0])
const foundItem = items.find(item => item.props.cplId === local.CplId);
setItemActive(foundItem)
})
10 replies
SSolidJS
Created by Gabriel Viol on 5/13/2024 in #support
Reactivity of my component
I studied the post a bit, did some tests, and came up with this solution. It works, but I wanted to know if this is the best solution in SolidJS?
const Component = (props) => {
const [ cpdId, setCplId ] = createSignal(pageStore.pageSettings.cplId)
const render = () => {
createEffect(() => {
setCplId(pageStore.pageSettings.cpdId)
})
return(
<Element cpdId={cpdId} />
)
}
return render()
}
const Component = (props) => {
const [ cpdId, setCplId ] = createSignal(pageStore.pageSettings.cplId)
const render = () => {
createEffect(() => {
setCplId(pageStore.pageSettings.cpdId)
})
return(
<Element cpdId={cpdId} />
)
}
return render()
}
10 replies
SSolidJS
Created by Gabriel Viol on 5/9/2024 in #support
Computations created outside a `createRoot` or `render` will never be disposed
I understand that I'm already using createStore here. Would it be best to add this country list to the store, even though it's a static list? And could this be why I'm getting this error? "Error: Hydration Mismatch. Unable to find DOM nodes for hydration key: 0-2-0-0-2-0-0-0-1-0-0-1-0-0-0-0"
11 replies