PluginProbe
Extendify / 0.9.2
Extendify v0.9.2
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / src / Library / hooks / useTestGroup.js

useTestGroup.js in Extendify 0.9.2, at src/Library/hooks/useTestGroup.js

23 lines 719 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useState, useLayoutEffect } from '@wordpress/element'
2 import { useGlobalStore } from '@library/state/GlobalState'
3 import { useUserStore as user } from '@library/state/User'
4
5 export const useTestGroup = (key, options, override) => {
6 const [group, setGroup] = useState()
7 const ready = useGlobalStore((state) => state.ready)
8
9 useLayoutEffect(() => {
10 if (
11 override ||
12 (ready && !group) ||
13 // Let the devbuild reset this
14 window.extendifyData._canRehydrate
15 ) {
16 const testGroup = user.getState().testGroup(key, options)
17 setGroup(testGroup)
18 }
19 }, [key, options, group, ready, override])
20
21 return group
22 }
23