Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/roact-compat/src/Portal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local ReactGlobals = require(Packages.ReactGlobals)

local warnOnce = require(script.Parent.warnOnce)

@[deprecated{ use = "ReactRoblox.createPortal()"}]
local function PortalComponent(props)
if ReactGlobals.__DEV__ and ReactGlobals.__COMPAT_WARNINGS__ then
warnOnce("Roact.Portal", "Please use the createPortal API on ReactRoblox instead")
Expand Down
3 changes: 3 additions & 0 deletions modules/roact-compat/src/RoactTree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type RoactHandle = {
parent: any, -- ROBLOX TODO: Instance?
}

@[deprecated{ use = "ReactRoblox.createRoot()"}]
local function mount(element: any, parent: any, key: string?): RoactHandle
if ReactGlobals.__DEV__ and ReactGlobals.__COMPAT_WARNINGS__ then
warnOnce("mount", "Please use the createRoot API in ReactRoblox")
Expand Down Expand Up @@ -95,6 +96,7 @@ local function mount(element: any, parent: any, key: string?): RoactHandle
}
end

@[deprecated{ use = "ReactRoblox.createRoot()"}]
local function update(roactHandle: RoactHandle, element)
if ReactGlobals.__DEV__ and ReactGlobals.__COMPAT_WARNINGS__ then
warnOnce("update", "Please use the createRoot API in ReactRoblox")
Expand All @@ -119,6 +121,7 @@ local function update(roactHandle: RoactHandle, element)
return roactHandle
end

@[deprecated{ use = "ReactRoblox.createRoot()"}]
local function unmount(roactHandle: RoactHandle)
if ReactGlobals.__DEV__ and ReactGlobals.__COMPAT_WARNINGS__ then
warnOnce("unmount", "Please use the createRoot API in ReactRoblox")
Expand Down
5 changes: 4 additions & 1 deletion modules/roact-compat/src/createFragment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ local React = require(Packages.React)

local warnOnce = require(script.Parent.warnOnce)

return function(elements)
@[deprecated{use = "React.createElement(React.Fragment, ...)"}]
local function createFragment(elements)
if ReactGlobals.__DEV__ and ReactGlobals.__COMPAT_WARNINGS__ then
warnOnce(
"createFragment",
Expand All @@ -28,3 +29,5 @@ return function(elements)
end
return React.createElement(React.Fragment, nil, elements)
end

return createFragment
28 changes: 21 additions & 7 deletions modules/roact-compat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ return {
-- Overlapping contents of public `React` interface
Component = React.Component,
PureComponent = React.PureComponent,
createElement = React.createElement,
createRef = React.createRef,
forwardRef = React.forwardRef,
createContext = React.createContext,
createElement = @[deprecated{ use = "React.createElement"}] function(...)
return React.createElement(...)
end,
createRef = @[deprecated{ use = "React.createRef"}] function(...)
return React.createRef(...)
end,
forwardRef = @[deprecated{ use = "React.forwardRef"}] function(...)
return React.forwardRef(...)
end,
createContext = @[deprecated{ use = "React.createContext"}] function(...)
return React.createContext(...)
end,
-- This public interface is aligned but is a deviation in React. It's
-- necessary to accommodate lua table semantics when merging state
None = React.None,
Expand Down Expand Up @@ -59,8 +67,14 @@ return {
Change = Shared.Change,

-- Binding interface entry-point for Roact-specific 'bindings' feature
createBinding = React.createBinding,
joinBindings = React.joinBindings,
createBinding = @[deprecated{ use = "React.createBinding()"}] function(...)
return React.createBinding(...)
end,
joinBindings = @[deprecated{ use = "React.joinBindings()"}] function(...)
return React.joinBindings(...)
end,

act = ReactRoblox.act,
act = @[deprecated{ use = "ReactRoblox.act()"}] function(...)
return ReactRoblox.act(...)
end,
}
3 changes: 3 additions & 0 deletions modules/roact-compat/src/oneChild.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ local ReactGlobals = require(Packages.ReactGlobals)

local warnOnce = require(script.Parent.warnOnce)

@[deprecated{
reason = "You likely don't need this at all! If you were assigning children via `React.oneChild(someChildren)`, you can simply use `someChildren` directly."
}]
local function oneChild(children)
if ReactGlobals.__DEV__ and ReactGlobals.__COMPAT_WARNINGS__ then
warnOnce(
Expand Down
5 changes: 4 additions & 1 deletion modules/roact-compat/src/setGlobalConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ local Packages = script.Parent.Parent
local ReactGlobals = require(Packages.ReactGlobals)
local warnOnce = require(script.Parent.warnOnce)

return function(_config)
@[deprecated{ use = "ReactGlobals.__DEV__"}]
local function setGlobalConfig(_config)
if ReactGlobals.__DEV__ and ReactGlobals.__COMPAT_WARNINGS__ then
warnOnce(
"setGlobalConfig",
Expand All @@ -29,3 +30,5 @@ return function(_config)
end
-- No equivalent behavior can be applied here
end

return setGlobalConfig