The identifier for the specific range facet.
An object containing range information, active state, and functions to update the range.
Is the range filter active
Max value
Min value
Range value
Toggle active state function
Update range function
General usage with useRange
:
import { useRange } from "@nosto/search-js/preact/hooks";
import { useState } from "react";
const Component = ({ facetId }) => {
const { min, max, range, active, toggleActive, updateRange } = useRange(facetId);
return (
<div>
<button onClick={() => toggleActive()}>
{active ? "Hide" : "Show"} Range Filter
</button>
{active && (
<div>
Current Range: {range[0]} to {range[1]}
<button onClick={() => updateRange([min, max])}>Reset Range</button>
</div>
)}
</div>
);
};
A hook that returns range information and functions to update the range.