local React = require("../../React") local ReactRoblox = require("../../ReactRoblox") type RenderedHook = { result: Result, rerender: (Props?) -> (), unmount: () -> (), } local function renderHook(callback: (Props) -> Result, props: Props?): RenderedHook local root = ReactRoblox.createLegacyRoot(Instance.new("Folder")) local hook = {} local function Component(props: Props) hook.result = callback(props) end function hook.rerender(newProps: Props?) props = newProps or props ReactRoblox.act(function() root:render(React.createElement(Component, props)) end) end function hook.unmount() ReactRoblox.act(function() root:unmount() end) end ReactRoblox.act(function() hook.rerender(props) end) return hook end return renderHook