@rbxts/uiblox 0.1.49 → 0.1.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,27 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
3
  local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
4
- local useCallback = _react.useCallback
4
+ local useEffect = _react.useEffect
5
5
  local useMemo = _react.useMemo
6
6
  local useState = _react.useState
7
7
  local themeProducer = TS.import(script, script.Parent.Parent, "context", "ThemeProducer").themeProducer
8
8
  local useTheme = function()
9
9
  local theme, setTheme = useState(themeProducer:getState())
10
- themeProducer:subscribe(function(state, _previousState)
11
- setTheme(state)
10
+ useEffect(function()
11
+ local unsubscribeFn = themeProducer:subscribe(function(state, _previousState)
12
+ setTheme(state)
13
+ end)
14
+ return function()
15
+ unsubscribeFn()
16
+ end
12
17
  end)
13
- local setProducerTheme = useCallback(function(t)
14
- themeProducer.setTheme(t)
15
- end, { setTheme })
18
+ local memoizedSetTheme = useMemo(function()
19
+ return themeProducer.setTheme
20
+ end, { themeProducer.setTheme })
16
21
  return useMemo(function()
17
22
  return {
18
23
  theme = theme,
19
- setTheme = setProducerTheme,
24
+ setTheme = memoizedSetTheme,
20
25
  }
21
26
  end, { theme, setTheme })
22
27
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/uiblox",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "description": "UI Library and theming for roblox-ts projects",
5
5
  "main": "out/init.lua",
6
6
  "scripts": {