I currently set my active state to 0:
const [active, setActive] = useState(0);
but I’m wondering how I can set the initial value to null if one of my component props: isFilterMode is true? So the initial state is "dynamic" based on the props?
>Solution :
Try like below
const [active, setActive] = useState(props.isFilterMode ? null : 0);
Or
using a callback function (lazy initialisation)
const [active, setActive] = useState(() => props.isFilterMode ? null : 0);