mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Fix theme component error regression
This commit is contained in:
@@ -5,6 +5,17 @@
|
|||||||
name. This isn't exactly best practice.
|
name. This isn't exactly best practice.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- Studio does not exist outside Roblox Studio, so we'll lazily initialize it
|
||||||
|
-- when possible.
|
||||||
|
local _Studio
|
||||||
|
local function getStudio()
|
||||||
|
if _Studio == nil then
|
||||||
|
_Studio = settings():GetService("Studio")
|
||||||
|
end
|
||||||
|
|
||||||
|
return _Studio
|
||||||
|
end
|
||||||
|
|
||||||
local Rojo = script:FindFirstAncestor("Rojo")
|
local Rojo = script:FindFirstAncestor("Rojo")
|
||||||
|
|
||||||
local Roact = require(Rojo.Roact)
|
local Roact = require(Rojo.Roact)
|
||||||
@@ -50,7 +61,7 @@ local StudioProvider = Roact.Component:extend("StudioProvider")
|
|||||||
|
|
||||||
-- Pull the current theme from Roblox Studio and update state with it.
|
-- Pull the current theme from Roblox Studio and update state with it.
|
||||||
function StudioProvider:updateTheme()
|
function StudioProvider:updateTheme()
|
||||||
local studioTheme = Studio.Theme
|
local studioTheme = getStudio().Theme
|
||||||
|
|
||||||
if studioTheme.Name == "Light" then
|
if studioTheme.Name == "Light" then
|
||||||
self:setState({
|
self:setState({
|
||||||
@@ -80,9 +91,7 @@ function StudioProvider:render()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function StudioProvider:didMount()
|
function StudioProvider:didMount()
|
||||||
local Studio = settings():GetService("Studio")
|
self.connection = getStudio().ThemeChanged:Connect(function()
|
||||||
|
|
||||||
self.connection = Studio.ThemeChanged:Connect(function()
|
|
||||||
self:updateTheme()
|
self:updateTheme()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user