-
import { createPagination } from '@solid-primitives/pagination'
import { type Component, createSignal } from 'solid-js'
const countPages = (pages: number) => { /* count pages */ }
const MyComponent: Component<{ pages: number }> = (props) => {
const [pagesCounter, setPagesCounter] = createSignal<number>(countPages(props.pages))
const [paginationProps, page, setPage] = createPagination({ pages: pagesCounter() })
// ...
} With 8:70 warning The reactive variable 'pagesCounter' should be used within JSX, a tracked scope (like createEffect), or inside an event handler function, or else changes will be ignored solid/reactivity |
Beta Was this translation helpful? Give feedback.
Answered by
rtritto
Sep 25, 2024
Replies: 2 comments
-
I fixed with: - const [pagesCounter, setPagesCounter] = createSignal<number>(countPages(props.pages))
- const [paginationProps, page, setPage] = createPagination({ pages: pagesCounter() })
+ const pages = countPages(props.pages)
+ const [pagesCounter, setPagesCounter] = createSignal<number>(pages)
+ const [paginationProps, page, setPage] = createPagination({ pages }) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rtritto
-
You could have just used untrack to convince eslint you're not interested in reactivity or used a memo for the paginationOptions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I fixed with: