from value
Should be called when size is changed
size value
Array of size options
to value
total value
import { useSizeOptions } from "@nosto/preact"
import { defaultConfig, sizes } from "../config"
export default () => {
const { from, to, size, total, handleSizeChange, sizeOptions } = useSizeOptions(sizes, defaultConfig.serpSize)
return (
<div>
<div>
{from} - {total < to ? total : to} of {total} items
</div>
{sizeOptions.length > 0 && (
<div>
<select
value={size}
onChange={e => handleSizeChange(e.target.value)}
>
{sizeOptions.map(v => (
<option value={v}>{v} items per page</option>
))}
</select>
</div>
)}
</div>
)
}
Preact hook that import size options to the component.