diff --git a/modules/roact-compat/src/Portal.lua b/modules/roact-compat/src/Portal.lua index c9ec77f5..a38039d6 100644 --- a/modules/roact-compat/src/Portal.lua +++ b/modules/roact-compat/src/Portal.lua @@ -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") diff --git a/modules/roact-compat/src/RoactTree.lua b/modules/roact-compat/src/RoactTree.lua index 8657cd31..5aeafcd0 100644 --- a/modules/roact-compat/src/RoactTree.lua +++ b/modules/roact-compat/src/RoactTree.lua @@ -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") @@ -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") @@ -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") diff --git a/modules/roact-compat/src/createFragment.lua b/modules/roact-compat/src/createFragment.lua index cb2b62e6..a95af0a6 100644 --- a/modules/roact-compat/src/createFragment.lua +++ b/modules/roact-compat/src/createFragment.lua @@ -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", @@ -28,3 +29,5 @@ return function(elements) end return React.createElement(React.Fragment, nil, elements) end + +return createFragment diff --git a/modules/roact-compat/src/init.lua b/modules/roact-compat/src/init.lua index 283b582f..8c986426 100644 --- a/modules/roact-compat/src/init.lua +++ b/modules/roact-compat/src/init.lua @@ -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, @@ -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, } diff --git a/modules/roact-compat/src/oneChild.lua b/modules/roact-compat/src/oneChild.lua index 59cdc068..92c2ae0a 100644 --- a/modules/roact-compat/src/oneChild.lua +++ b/modules/roact-compat/src/oneChild.lua @@ -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( diff --git a/modules/roact-compat/src/setGlobalConfig.lua b/modules/roact-compat/src/setGlobalConfig.lua index 86a22da5..dbfbc7df 100644 --- a/modules/roact-compat/src/setGlobalConfig.lua +++ b/modules/roact-compat/src/setGlobalConfig.lua @@ -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", @@ -29,3 +30,5 @@ return function(_config) end -- No equivalent behavior can be applied here end + +return setGlobalConfig