• React hook for working with a ScrollGroupScrRef. Returns a value and a function to set the value for both the ScriptureReference and the ScrollGroupId for the provided scrollGroupScrRef. Use similarly to useState.

    Parameters

    • scrollGroupScrRef: undefined | ScrollGroupScrRef

      ScrollGroupScrRef representing a scroll group and/or Scripture reference. Defaults to 0 meaning synced with scroll group 0 (A in English)

      WARNING: MUST BE STABLE - const or wrapped in useState, useMemo, etc. The reference must not be updated every render

    • setScrollGroupScrRef: (scrollGroupScrRef: ScrollGroupScrRef) => boolean

      Function to run to set scrollGroupScrRef. Should return true if actually updated any properties; false otherwise

      Note: this parameter is internally assigned to a ref, so changing it will not cause any hooks to re-run with its new value. This means that updating this parameter will not cause a new callback to be returned. However, because this is just used when needed and doesn't have any reason to render changes, this has no adverse effect on the functionality of this hook. It will always set using the latest value of this callback

    Returns [
        scrRef: ScriptureReference,
        setScrRef: (newScrRef: ScriptureReference) => void,
        scrollGroupId: number,
        setScrollGroupId: (newScrollGroupId: undefined | number) => void,
    ]

    [scrRef, setScrRef, scrollGroupId, setScrollGroupId]

    • scrRef: The current value for the Scripture reference this scrollGroupScrRef represents
    • setScrRef: Function to use to update the Scripture reference this scrollGroupScrRef represents. If it is synced to a scroll group, sets the scroll group's Scripture reference
    • scrollGroupId: The current value for the scroll group this scrollGroupScrRef is synced with. If not synced to a scroll group, this is undefined
    • setScrollGroupId: Function to use to update the scroll group with which this scrollGroupScrRef is synced