{"id":"jsdotlua/react-is","name":"react-is","scope":"jsdotlua","platform":"roblox","description":"Mirrored from the Wally registry.","version":"17.2.1","latest":"17.2.1","versions":["17.0.1","17.0.2","17.0.3","17.0.4","17.1.0","17.2.0","17.2.1"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{"jsdotlua/shared":{"version":"^17.2.1","alias":"shared"}},"integrity":"0951639382b8a861d24e3fec67b10832f6d3bb5ac9fc3fda9fbe05baa360f886","likes":0,"downloads":793,"install":"forest install jsdotlua/react-is","url":"https://forest.dev/p/roblox/jsdotlua/react-is","files":"https://api.forest.dev/ai/package/roblox/jsdotlua/react-is/files","readme":"# `react-is`\n\nThis package allows you to test arbitrary values and see if they're a particular React element type.\n\n## Usage\n\n### Determining if a Component is Valid\n\n```lua\nlocal React = require(Path.To.React)\nlocal ReactIs = require(Path.To.ReactIs)\n\nlocal ClassComponent = React.Component:extend(\"ClassComponent\")\n\nfunction ClassComponent:render()\n    return React.createElement(\"Frame\")\nend\n\nlocal function FunctionComponent()\n\treturn React.createElement(\"Frame\")\nend\n\nlocal ForwardRefComponent = React.forwardRef(function(props, ref)\n\treturn React.createElement(FunctionComponent, {\n\t\tforwardRef = ref,\n\t})\nend)\n\nlocal Context = React.createContext(false)\n\nReactIs.isValidElementType(\"Frame\") -- true\nReactIs.isValidElementType(ClassComponent) -- true\nReactIs.isValidElementType(FunctionComponent) -- true\nReactIs.isValidElementType(ForwardRefComponent) -- true\nReactIs.isValidElementType(Context.Provider) -- true\nReactIs.isValidElementType(Context.Consumer) -- true\n```\n\n### Determining an Element's Type\n\n#### Context\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal React = require(ReplicatedStorage.Packages.React)\nlocal ReactIs = require(ReplicatedStorage.Packages.ReactIs)\n\nlocal ThemeContext = React.createContext(\"blue\")\n\nReactIs.isContextConsumer(React.createElement(ThemeContext.Consumer)) -- true\nReactIs.isContextProvider(React.createElement(ThemeContext.Provider)) -- true\nReactIs.typeOf(React.createElement(ThemeContext.Provider)) == ReactIs.ContextProvider -- true\nReactIs.typeOf(React.createElement(ThemeContext.Consumer)) == ReactIs.ContextConsumer -- true\n```\n\n#### Element\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal React = require(ReplicatedStorage.Packages.React)\nlocal ReactIs = require(ReplicatedStorage.Packages.ReactIs)\n\nReactIs.isElement(React.createElement(\"Frame\")) -- true\nReactIs.typeOf(React.createElement(\"Frame\")) == ReactIs.Element -- true\n```\n\n#### Fragment\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal React = require(ReplicatedStorage.Packages.React)\nlocal ReactIs = require(ReplicatedStorage.Packages.ReactIs)\n\nReactIs.isFragment(React.createElement(React.Fragment)) -- true\nReactIs.typeOf(React.createElement(React.Fragment)) == ReactIs.Fragment -- true\n```\n\n#### Portal\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal React = require(ReplicatedStorage.Packages.React)\nlocal ReactRoblox = require(ReplicatedStorage.Packages.ReactRoblox)\nlocal ReactIs = require(ReplicatedStorage.Packages.ReactIs)\n\nlocal container = Instance.new(\"Folder\")\nlocal portal = ReactRoblox.createPortal(React.createElement(\"Frame\"), container)\n\nReactIs.isPortal(portal) -- true\nReactIs.typeOf(portal) == ReactIs.Portal -- true\n```\n\n#### StrictMode\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal React = require(ReplicatedStorage.Packages.React)\nlocal ReactIs = require(ReplicatedStorage.Packages.ReactIs)\n\nReactIs.isStrictMode(React.createElement(React.StrictMode)) -- true\nReactIs.typeOf(React.createElement(React.StrictMode)) == ReactIs.StrictMode -- true\n```\n","readmeBorrowedFrom":{"version":"17.0.4","source":"wally"},"readmeTruncated":false}