In this instalment Iād like to tell you about ReactJS, and Iāll take the chance to announce a brand new course of mine: Adobe UXP plugins development with ReactJS - Build products and Create a Business in the Creative Cloud Marketplace and Beyond.
So far in this series Iāve only used Vanilla JavaScript to keep it simple, but in the real world a large part of plugin developers donāt like to reinvent the wheel themselves and end up using one of the available frameworks. And guess what, ReactJS is the most popular JavaScript library according to the StackOverflow 2021 survey. Even more than jQuery, check that out!
By the way, React JS is a Library and not a Framework (such Vue.js or Angular), do you know the difference? A Library is something that you āplug in your codeā, whereas a Framework is something āyou plug your code intoāā¦ subtle but meaningful difference! In other words, your code uses a Library, whereas your code is used by a Framework. This is what is generally referred to as āInversion of Controlā.
According to this definition, it turns out that React JS is in fact a library, i.e. some code that enhances āregularā JavaScript adding useful features, but it doesnāt require you to buy into some opinionated way of structuring your source code, as Frameworks generally do.
React feats
So, what kind of feats made React JS so popular over the years? First of all, Components, a handy way to bundle into a custom element bits of user interface and logic.
Creating a component is as easy as writing a function: that in React can return markup, i.e. HTML elements.
This is referred to as JSX: JavaScript Syntax Extension, or JavaScript XML. Those components can be passed Properties by the parent: they can make use of them, e.g. to display values via curly braces {}
interpolation or to do whatever they have to do.
Here weāre passing a message
and a bigger
properties, that are then destructured and used in the component to set the Spectrum Button text and assign classes.
Thanks to Hooks, special React functions that give Components superpowers, you can e.g. create a State: a reactive property (alongside with its setter) that is able to trigger a component re-render when the property changes.
In the example above, isOn
is a boolean stored in the State; depending on its value, a different string is displayed in the Spectrum Action Button. The boolean is flipped in the buttonās onClick
handler via its setter setIsOn()
.
Reactivity is key here: youāre building declarative interfaces based on data, that are going to reflect changes in data as they happen. On the other side, with imperative code (e.g. jQuery) you have got to explicitly impart instructions to the UI on what to do, and when.
Obviously thereās much more to React than Components and Hooks, but thanks to them and to JSX (the possibility to use JavaScript to compute HTML code) youāre able to build remarkably powerful User Interfaces.
For all your needs there is a large ecosystem of plugins: take State Management as an exampleāi.e. a unique place to store reactive data that is accessible to all components no matter their parent/child relation. React provides you with solid foundations only, but you can easily plug-in the library you like the most among the available ones: Redux, Recoil, MobX, Zustand, etc.
Why React
And not Vue, Angular, Svelteā¦? Because: Adobe! You might not like this, but let me explain.
UXP, as weāve seen over and over again throughout this series, is heavily inspired by standards, but it shouldnāt be considered a Browser environment. Hence, not everything that works in a Browser is to be expected to automatically work in a UXP plugin. As an example, until very (very!) recently, there wasnāt a document.createEvent()
method, which is what Vue.js version 3 relies upon. Why was it missing? Because the UXP team has to willingly implement features, and that one didnāt happen to be high priority to them. As a result, for almost a year after the UXP announcement you couldnāt even load Vue.js v3.1
It also happens that React JS is exactly what Adobe uses for their own first-party features, like for instance the Welcome screen, the New File dialog, the Neural Filters interfaces: all UXP plugins. And you can bet that if React-next-version is going to need some Browser API that didnāt make into UXP yet, that very feature is going to be implemented at once. Because they wonāt risk Neural Filters to crash because of it, right? On the other hand, any other feature might take months to be implementedāas itās happened with document.createEvent()
In other words, not only React is a solid choice thanks to the popularity of the library in the JavaScript ecosystem and the amount of available resources; given its adoption by Adobeās engineering teams it has to be considered the safest choice, support-wise.
With any other framework, although they might work, youāreā¦ more on your own. The [insert your framework of choice] might or might not work now, and might stop working when its newer version is released. ĀÆ\_(ć)_/ĀÆ
The UXP and React JS course
I was chatting with a developer friend once, and they said: āIāll start with Vanilla JS plugins, and when Iām familiar with the environment Iāll approach React JS. You know, I donāt want too much on my plateā. Although it may sound considerate at first, I donāt buy it, IMHO thereās a way better approach.
On the one side, learning a tool2 such as React for Reactās sake, in some abstract/generic environment Ć la āletās build a Todo app, or a Reddit cloneā is always going to be an inferior way, compared to learning it in the actual context in which youāre gonna use it: a UXP plugin. Not only youāre gonna save a huge lot of time, but it sucks way less.
Provided that somebody (i.e. yours truly) has figured out a learning path that combines UXP and React JS in such a way that youāre presented with a UXP problem, and given a gradually more complex React tool to solve it. So, hopefully, next time youāll run into the same kind of problem in your own UXP plugins, itāll come natural for you to reach out for that same React tool to hammer it. Much better than trying to fit some abstract example into the case at hand.
Moreover, thereās a small(ish) subset of React features that allow you to accomplish a great deal of good in the UXP environment. Everybody love Venn Diagrams, isnāt that right?
The overlapping area is evident after youāve drawn the two circles, i.e. after youāve learned the two topics separately. But while youāre drawing (i.e. learning) them on your own? Youāve no idea whether the React JS topic youāre approaching is going to be of fundamental importance, marginal, or just a waste of time. Wouldnāt it be better to start from this relatively approachable core of super-important topics instead, dealt with in the UXP plugins context to optimize your energies and time?
Thatās precisely the Adobe UXP plugins development with React JS courseās agenda.
Subtitled: āBuild products and Create a Business in the Creative Cloud Marketplace and Beyondā. Thereās a fat section on the business of UXP plugins, from mundane but fundamental topics such as VAT, ecommerce providers etc. that I wish somebody told me when I started many years ago, up to a comparison of marketing strategies. With examples from a barely average marketeer and a very successful one (and by very successful I mean in the six-figures range) such as Micheal Bruny-Groth, the author of the Logo Package for Adobe Illustrator.
The course consists of a PDF ebook, ~290 pages lusciously typeset in LaTeX (a pain in the ass, but still luscious).
Then there are 16 demo plugins with fully commented code, from the ubiquitous āAction buttonsā plugin, up more advanced topics such as React custom hooks, server-side communication, etc.
Iāve also recorded 5 and a half hours of videotutorials, with theory, live coding, bug fixing and whatnot.
I definitely plan to add more content as UXP evolves. The course is offered in three different packages:
- Basic: Book + Code samples
- Complete: Book + Code samples + Videos (streaming only)
- Enterprise: Book + Code samples + Videos (downloadable, licensed for teams up to 10 seats strong)
For more info and FAQ check out the course home at PS-Scripting.com.
Thanks for following along! If you find this content useful, please consider supporting me: you can either purchase my latest UXP Course with ReactJS, or donate what you can like the following fine people didāitāll be much appreciated! šš»
Thanks to: John Stevenson āļø, Adam Plouff, Dana Frenklach, Dmitry Egorov, Roberto Sabatini, Carlo Diamanti, Wending Dai, Pedro Marques, Anthony Kuyper, Gabriel Correia, Ben Wright, CtrlSoftware, Maiane Araujo, MihĆ”ly DĆ”vid Paseczki, Caspar Shelley.
Stay safe, get the Nth vaccine shot if/when you can ā bye!
The whole series so far
- #01 ā Rundown on the UXP announcement @ the Adobe MAX 2020
- #02 - Documentation
- #03 - UXP Developer Tool
- #04 - Commands vs. Panels and the manifest.json
- #05 - Sync vs. Async code in Photoshop DOM Scripting
- #06 - BatchPlay (part 1): the ActionManager roots
- #07 - BatchPlay (part 2): Alchemist as a UXP Script Listener
- #08 - BatchPlay (part 3): Alchemist as a UXP Inspector
- #09 - Adobe Spectrum UXP
- #10 - Modal Dialogs
- #11 - Flyout Menus and Entrypoints
- #12 - React JS and the UXP plugins Course
- #13 - Manifest v5
- #special - The UXP Landscape Guide