React Documentation
How do you find further documentation on React?
Why is there no API documentation for react-lua
?
Because react-lua
is a transpilation of React, the API is the same as React. The only difference is that the API is in Lua instead of JavaScript/TypeScript.
React is agnostic of the rendering engine, and needs specific implementations (renderers) to work on different platforms. It is for this reason that React Native uses the same React Core as React DOM (the browser-based DOM renderer), but has a different renderer.
Similarly, react-lua
has the react-roblox renderer for integration with the Roblox DOM / API.
React Docs
The current React documentation is available at react.dev.
react-lua
is based on React 17, so the documentation for that version is the most relevant.
As react-lua
is a port of React, the documentation for React is also applicable to react-lua
.
For example, for useEffect
:
- TypeScript
- Luau
import { useState, useEffect } from 'react';
export default function Page({ user }) {
const [person, setPerson] = useState('Alice');
useEffect(() => {
const { firstName, lastName } = user;
setPerson(`${firstName} ${lastName}`)
}, [user]);
...
};
local React = require(ReplicatedStorage.Packages.React)
local useState, useEffect = React.useState, React.useEffect
local function Page(props)
local person, setPerson = useState('Alice')
useEffect(function()
local firstName, lastName = props.user.firstName, props.user.lastName
setPerson(firstName .. ' ' .. lastName)
end, { props.user })
...
end
return Page
Caveats
The following are not implemented in react-lua
(as they weren't introduced in React 17, although there are other features that are not implemented):