@rbxts/uiblox 0.1.22 → 0.1.24

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.
@@ -4,6 +4,7 @@ local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
4
4
  local React = _react
5
5
  local useState = _react.useState
6
6
  local useMemo = _react.useMemo
7
+ local useEffect = _react.useEffect
7
8
  local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
8
9
  local useAsyncEffect = _pretty_react_hooks.useAsyncEffect
9
10
  local useDeferState = _pretty_react_hooks.useDeferState
@@ -77,15 +78,16 @@ local function Preloader(props)
77
78
  local _assetId = assetId
78
79
  setCurrentAsset(contentNamesById[_assetId])
79
80
  setPercentage(function(prev)
80
- local newPercentage = math.clamp(prev + unit, 0, 100)
81
- if newPercentage == 100 then
82
- setLoaded(true)
83
- end
84
- return newPercentage
81
+ return math.clamp(prev + unit, 0, 100)
85
82
  end)
86
83
  end)
87
84
  setCurrentAsset(nil)
88
85
  end), {})
86
+ useEffect(function()
87
+ if math.round(percentage) >= 100 then
88
+ setLoaded(true)
89
+ end
90
+ end, { percentage })
89
91
  local percentageStr = useMemo(function()
90
92
  if not showPercentage then
91
93
  return nil
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/uiblox",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "UI Library and theming for roblox-ts projects",
5
5
  "main": "out/init.lua",
6
6
  "scripts": {