# extendify/0.5.0/src/hooks/useTestGroup.js

Extendify, version 0.5.0. 17 lines.

- Page: https://pluginprobe.com/plugins/extendify/0.5.0/code/src/hooks/useTestGroup.js
- Raw: https://pluginprobe.com/plugins/extendify/0.5.0/raw/src/hooks/useTestGroup.js
- Modified: 2022-02-23T01:03:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/0.5.0/code/src/hooks/useTestGroup.js#L10-L20`.

```javascript
import { useState, useLayoutEffect } from '@wordpress/element'
import { useUserStore } from '@extendify/state/User'

export const useTestGroup = (key, options) => {
    const [group, setGroup] = useState()
    const testGroup = useUserStore((state) => state.testGroup)

    useLayoutEffect(() => {
        // Let the devbuild reset this
        if (!group || window.extendifyData.devbuild) {
            setGroup(testGroup(key, options))
        }
    }, [key, options, group, testGroup])

    return group
}

```
