In complex views of our app, we have loads of components and elements being rendered on the page. E.g. a form that has dozens of sections and fields. Or, a table that has ~100-200 rows.
Unfortunately, in one of our Plasmic apps, we’ve reached a point where some of our pages are that complex — and because of that, we can’t afford rerendering everything whenever user interacts with the page. (As a simple click event blocks our UI now for as long as 0.5-1.5s.)
The solution to that is to decrease the number of components that get rerendered at once. For example, if a row gets selected/deselected, only that row should be rerendered. React shouldn’t need to completely rerender all of the remaining rows. Or, if a form field gets changed, only section related to it should rerender. React shouldn’t need to rerender the whole form.
In the normal React development, we’d add key={...}
property to the row component. And wrap a few of our components with React.memo
, so they don’t rerender when not needed. Such optimizations would usually be enough to make the whole complex view render quick and nicely.
How can we do that in Plasmic? I’m afraid currently that’s not possible. Do you have any plans for this? So that we can optimize the Plasmic-generated code where needed, so that the interface feels responsive to the clients? For example:
- There could be a switch allowing to turn on/off
React.memo
for a certain component. - When elements are repeated, there could be additional “collection key” attribute used for the
key={...}
React attribute. ( Rendering Lists – React )
If you don’t plan any of that, what workarounds to this problem do you recommend? Besides of course asking our designers to redesign the app, so that the views are less complex.