I had a very hard time getting started with react-lua myself. This guide aims to clear up some of the confusion I ran into. There are definitely some unfortunate hurdles in getting started with react-lua, especially when it comes to importing the library into your project and getting a your first UI to render. Once you get past these hurdles, I think react-lua is a really great choice for UI development.
Modern react is much more straightforward and easy to use than it use to be. Functional components and hooks fill the need for confusing class component definitions or rodux for state management. If you had a bad experience using Roact, I hope youâll consider giving react-lua another go following this guide!
Still, React is definitely not the most straightforward tool learn and use. I think working with UI instances directly or other UI libraries like fusion are also great choices⌠Whatever you choose, just make sure youâre learning and having fun :D.
One thing you get is all the package support thatâs already within the React ecosystem, it just needs to be translated. For example some of the React touchscreen handler libraries, which would be a pain to implement yourself. You also get to use a almost 1:1 translation of React, compared to Roact which had multiple deviations and performance issues.
I personally strongly disagree with usage of react-lua. Several engineers I work with strongly refuse to utilize such framework.
I agree with @AbstractAlex. I personally believe the current UI tools are fine, I dislike the fact you canât visually see what your working on without a play-test or custom plugin. Framework just seems unnecessary.
I think working with native UI tools starts running into challenges when you want to manage very dynamic UIs. Things that might be difficult to model directly in the Studio WYSIWYG style editor.
Part of the magic of many Roblox experiences is in their simplicity so I really value your perspective too! Like, UI doesnât need to be complex often times games will be better like this!
This can be done with any framework that has a component/class system, and it does not have to be declarative and a complete mess to read.
*all projects
Quite the understatement.
EDIT
let me just add that the reason so many people dislike roact/react/fusion etc is that Itâs incredibly convoluted.
What serious advantage do these frameworks provide after all of the convolution? A component system. Thatâs literally it.
to back this up
want proof of it being convoluted? reread the post
what is the big advantage that everyone cites when talking about these frameworks? that you can reuse components. This is the only significant feature that is missing from the default roblox scripting environment, hence why everyone flocks to frameworks that provide it.
Any framework that has reusable components can accomplish anything that react-lua can. Forcing yourself in to the declarative paradigm has some drawbacks.
By using react, you are somehow justifying:
Creating ui purely in code, not visually, even though the entire point of ui is to be a visual interface
Using plenty of incredibly unintuitive, and frankly, spaghetti features to create simple systems (other frameworks can provide features in much simpler ways, except you wouldnât know that because you only use declarative ui)
My main issue with react, is that its bloated and unintuitive. This goes against (what I believe) is a primary goal of the roblox engine: to be simple, intuitive and beginner friendly. Thereâs no reason that this paradigm canât continue in to powerful ui frameworks. I donât think its hard to understand why react-lua isnât beginner friendly nor intuitive.
The point Iâm making is there is a better way to do ui.
Nobody claimed otherwise. However, React is the industry standard for a reason (actually, several).
Hey man if you donât know how to write clean and organized code, React really isnât going to help you.
So donât use it. I donât understand what your problem is. I really donât even know why you bothered to reply. Your post doesnât add anything useful or valuable to the discourse and literally just amounts to âI think React is stinky.â Thereâs no meaningful critiques of React or how it works. You legitimately just posted âReact stinkyâ phrased several different ways.
I donât know how you turned the idea of âreact (react-lua) code being a mess to readâ to âwriting react code is unorganizedâ.
Never did I say that react is unorganized, in fact, I think its incredibly organized. I mean, its declarative, how more organized can you get?
The point I was making was itâs unnecessarily convoluted and not what you would call âcleanâ when reading. Ideally, code doesnât need comments or extra explanation, because its so simple and clear you can understand what its doing just by reading it. This is not how most people would describe declarative ui, at least on Roblox.
There are a lot more advantages to React than a component system. The biggest is the declarative nature. Imperative UI makes reflecting complex state bug prone and flaky. With React, it will reflect the state of your UI automatically and in the most optimal way possible.
For me, declarative frameworks are all about making complex state easier to reflect.
No. These kinds of sweeping and ill informed statements are not useful. I work on a game called Clip It. It has incredibly complex UI and simply would not exist without React today. Weâre a 5 person team working on, essentially, a mobile app in Roblox. Weâre doing a lot of work to make the UI feel like a native experience.
Clip It is composed of hundreds of components. I think weâre well over 200,000 lines of UI related code now. What weâre doing would simply be too much work without a declarative framework.
Can you be more explicit about what makes declarative spaghetti? Speaking from many years of experience using both approaches, imperative UI is a lot more prone to ending up spaghetti once you start manually reconciling complex state.
Also, complex UI like the ones in Clip It are far from simple systems. I think you massively underestimate how hard UI is when you go beyond simple screens.
It seems to be sufficient enough to assign a non-sense that I called P_Free as a Free Variable. Eventually, this will break in the future, with the unknown type⌠But I hope that it wonât.
The other way would be typeof(table.clone()) where the argument is empty. This returns a {- -} but the new type solver breaks it as well, by turning it into {+ +}
This will allow autocompletion in the properties field. For now
This is due unifications not showing up as a type. But other than that, I think it works.
This is the best so far that I could pull out from type definitions.
I think not every Roblox Component puts everything inside props though. SoâŚ
To completly test it out.
Seems to work.
I wouldnât see how keyof would solve it automatically.
Files were ReactBaseClasses and React all under react
Absolutely wild take man, this isnât Roact anymore.
Robloxâs new React module is incredibly fast and typechecked. It has substantially sped up my workflow, and made it far easier to have a universally communicated paradigm for developing UI.
Combined with Hoarcekat, Iâm able to edit, preview, and even interact with changes to my UI in real time from edit mode. This has been a huge game changer for my productivity. I donât have to keep restarting the game each time I want to test a change to my UI.
Manually having to hook up connections and having to manually manage the creation, destruction, visibility, etc. of elements in my UI has always been a hacky sloppy mess. I always hated writing UI code, but @grilme99 showed me the light and Iâm not turning back anymore.
This is how I feel too. (Welcome to the frameworks club, by the way!)
I canât go back from using Fusion or React or something now. For the kinds of problems Iâve encountered in my UI development workflows, frameworks have proven that they can solve them. Iâve shipped tens of thousands of completely new lines of code with my latest plugin releases, and so far Iâve had absolutely zero bug reports to go and fix.
For people who donât have the problems that UI frameworks solve, theyâre totally a waste of time, and thatâs where I see Alexâs side of things. But if you have the problems these frameworks solve for, then itâs just no contest.
This even applies to the choice of framework specifically. You get different solutions from different vendors, and you pick the one that fixes your problems.
This resource has the same issues as all the other resources available on react-lua. It shows very primitive examples with no features and would never be implemented in a game.
I get how to do all that stuff but how do you animate? Logically as a Roblox developer, youâd think youâd use TweenService and useRef to get the GUIObject reference, but thatâs not what youâre supposed to do.
Itâs not easy as you have to either write your library for it, use an existing one (of which they are usually poorly documented or use roblox-ts, so you canât understand them unless you know JS), or use this one useClock example Iâve found.
We need more UI examples that have been implemented with react-lua in actual games so people can dig through the code and learn from it.
To me, itâs just something that returns a something.
React seems to pass that functionâs arguments as well. Aslong the function are using props.
The only thing I am currently interested in about React, is the Developer Framework. If Robloxâs Developer Framework, doesnât use props itâs pointless, and props would still not show up in the autocomplete.
Â
Returning functions directly through a module without putting it in a table, also has Reloading issues when testing on Studio.
This isnât my post, but thatâs super useful feedback. Iâm going to try and get a tech blog for Clip It cooked up soon and I should be able to write some articles that cover more of the âmeatâ of using React. Will prioritize an animations blog post.
If youâre hesitant about using React because you need to run the code to see changes, tools like Hoarcekat or UILabs have you covered.
Hoarcekat: Simplifies the process by allowing you to write stories (.story.lua) and render them directly within the provided plugin. Hoarcekat has support for Luau and transpiled Roblox-TS code.
UILabs: Offers a more advanced approach. It not only supports Hoarcekatâs story syntax but also introduces controls. These controls enable you to adjust your UIâs properties without modifying the story or creating multiple duplicate versions. UILabs was written using Roblox-TS but does also have support for Luau.
Learning to use a declarative UI library can be challenging, especially when it comes to quickly testing and iterating. However, with these tools, that hurdle is virtually eliminated, making the process much smoother.
Thank you, I am glad you agree and I did not mean for my post to come across as negative. I have tried using React in my game to see if it would be a good fit and I ran into a myriad of problems as I mentioned in my reply, and the lack of resources and guides on how to deal with it made me quite frustrated with the whole process.
I am highly appreciative that a Roblox staff member took the time and made a detailed post like this.