Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.
/ roact-hookify Public archive

Use and implement hooks in Roact

License

Notifications You must be signed in to change notification settings

Reselim/roact-hookify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

local counter = hookify(function()
	local count, setCount = hookify.useState(0)

	return Roact.createElement("TextButton", {
		Text = ("Current count is %d"):format(count),
		TextSize = 24,

		Position = UDim2.new(0.5, 0, 0.5, 0),
		AnchorPoint = Vector2.new(0.5, 0.5),

		BackgroundTransparency = Color3.new(1, 1, 1),

		[Roact.Event.Activated] = function()
			setCount(count + 1)
		end
	})
end)

Hooks documentation on React

About

Use and implement hooks in Roact

Resources

License

Stars

Watchers

Forks

Languages