Config Driven UI using ReactJS

Rate this content
Bookmark
Slides
The video talk explores the concept of config-driven UI using ReactJS, a method to create dynamic and customizable user interfaces using configuration files like JSON. The talk explains how the base UI layer with a wizard menu can dynamically render components based on a single config file. It delves into the layout part, which uses a recursive structure to hold vertically and horizontally stacked elements, and describes the role of the LayoutRenderer component in parsing and rendering the UI. The talk also highlights the benefits of config-driven UI, such as ease of modification and reusability of components across different pages or scenarios.

From Author:

We at Microsoft are rethinking the way we use ReactJS as frontend devs, traditional React UI Design patterns results in redundant code, making code maintainability cumbersome. By making UI Config driven we supercharged React components by making config file a single source of truth, The above approach made it easier to onboard new UI scenarios quickly and with minimal regression in the old UI Flows, resulting in a significant reduction in dev efforts, the best part is all the code was kept in Typescript only no XML or other declarative languages were used.

This talk has been presented at React Day Berlin 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

Config-driven UI is a technique that allows you to create user interfaces based on a configuration such as JSON or a TypeScript file that defines the layout and content of the UI components. This approach is useful for creating dynamic and customizable UIs without hard-coding them.

Config-driven UI benefits developers by allowing them to easily change the UI by modifying a configuration file, such as JSON, without touching the other code. It also enables reuse of the same components across different pages or scenarios by providing different configuration files.

Config-driven UI can be implemented in ReactJS using various approaches. One possible approach involves using React Hooks and custom components. The idea is to define the layout using a recursive structure for vertical and horizontal stacked elements and map leaf nodes to the actual content to be displayed.

The layout part of config-driven UI consists of three types of components: Element, Vertical, and Horizontal. 'Element' represents a single UI component like a dropdown or chart. 'Vertical' and 'Horizontal' are containers that allow stacking elements vertically or horizontally, and they can be nested to create complex layouts.

The 'type' property specifies the type of the component in a config-driven UI. For example, it can indicate whether the component is a dropdown, chart, form, etc.

The 'config' property in a config-driven UI setup contains an 'id' property that uniquely identifies the component, along with other properties that help in drawing the component.

In ReactJS, the layout is rendered in a config-driven UI by creating a custom component called LayoutRenderer. This component takes the JSON configuration file as a prop, uses React hooks to parse it, and recursively renders the layout based on the configuration.

The LayoutRenderer component in ReactJS is used to render the UI layout based on a JSON configuration file. It parses the JSON config using React hooks and recursively calls itself to render each child component, whether it is a vertical or horizontal element.

Yes, the same config-driven layout can be used for different scenarios by providing different JSON configuration files. This allows for easy customization and reusability of UI components across various use cases.

Viewers can reach out to the speaker, Joban, on LinkedIn, Twitter, or the Discord server for more details. The speaker encourages viewers to ping him anytime with questions.

Joban Singh
Joban Singh
7 min
12 Dec, 2023

Comments

Sign in or register to post your comment.

Video Transcription

1. Introduction to Config-driven UI using ReactJS

Short description:

Hello everyone, and welcome to a lightning talk on config-driven UI using ReactJS. Config-driven UI is a technique that allows you to create dynamic and customizable UIs without hard-coding them. You use a JSON file that specifies the type, size, position, and data source for each component. Now let's understand this in detail. We have a base UI layer with a wizard menu consisting of various styles. The idea is to have a single config file for all the tiles and render them on the go by reading the config. In React.js, we can implement this using React Hook and custom components. Let's start with the layout part, which uses a recursive structure to hold vertically and horizontally stacked elements.

Hello everyone, and welcome to a lightning talk on config-driven UI using ReactJS. In this video, I'll explain what config-driven UI means and how we can do it in ReactJS. But first, a brief intro about me. Hey guys, I'm Joban and I've been working at Microsoft for the past two years and you guys can reach out to me on the below handles. And so, without further ado, let's get started.

So what is config-driven, right? What it means. Config-driven UI is a technique that allows you to create user interfaces based on a configuration such as JSON or a TypeScript file that defines the layout and content of the UI components. This can be useful for creating dynamic and customizable UIs without hard-coding them. For example, let's say you want to create a dashboard that shows different types of data visualizations and summaries. Instead of writing JSX code for each component and arranging them in a fixed layout, you use a JSON file that specifies the type, size, position, and data source for each component. And then, you can create a custom component that reads that JSON file and renders the UI accordingly. So this way, you can easily change the UI by modifying the JSON file without even touching the other code. You can also reuse the same component from different pages or for different scenarios by providing different JSON files.

Moving on. Now let's understand this a bit in detail. So here we can see a base UI layer on top of which there is a wizard menu which consists of various styles, number one, number two, number three, etc. And each style has a bunch of components a, b, c, etc. The V and the H on the left side, you can see, represents whether the layout setting of each component is whether it's a horizontal or a vertical component, right? We'll come to that what it means. Now for the tile two we can have a very similar UI as tile number one with slight change in the component layout. You can see here, sorry. Similarly for tile number three also has minor differences in the UI. Now the idea here is to not create separate files for each style as the UI differences are very minor, right? But to have a single config file for all the tiles and we render the tiles on the go by reading the config, right?

So how can we do this in React.js? Well, there are many ways to implement, to be honest, this config-driven UI paradigm. But in this talk I'll show you one of the possible approaches using React Hook and custom components. The basic idea is to have two parts. One to define the layout, which uses a recursive structure to hold vertically and horizontally stacked elements. And another to map leaf nodes to the actual content that needs to be displayed. The actual implementation of a smallest unit of component, right? For example, a dropdown. It can be a form, it can be a chart, right? Let's start with the layout part. On the screen you can see the layout part consists of three types of components. First is element and then vertical and horizontal.

2. Config-driven UI Components

Short description:

Element is the leaf node representing a UI component. Vertical and horizontal containers stack elements either vertically or horizontally, including nested layouts. The type and config properties specify the component's type and unique identifier. The children property creates nested UIs.

Element is the leaf node that represents a single UI component, such as a dropdown, a chart, and a form, as I already said. Vertical and horizontal are containers on top of those elements, which allows us to stack elements either vertically or horizontally. It provides us that information. These containers can also be nested inside each other to create complex layouts. The type property specifies the type of the component. The config property contains an id property as well, which uniquely identifies the component. The other properties that help you to draw the component. The children property is an array of child nodes that follow the same format to create nested UIs.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
Understanding React’s Fiber Architecture
React Advanced Conference 2022React Advanced Conference 2022
29 min
Understanding React’s Fiber Architecture
Top Content
This Talk explores React's internal jargon, specifically fiber, which is an internal unit of work for rendering and committing. Fibers facilitate efficient updates to elements and play a crucial role in the reconciliation process. The work loop, complete work, and commit phase are essential steps in the rendering process. Understanding React's internals can help with optimizing code and pull request reviews. React 18 introduces the work loop sync and async functions for concurrent features and prioritization. Fiber brings benefits like async rendering and the ability to discard work-in-progress trees, improving user experience.
The Eternal Sunshine of the Zero Build Pipeline
React Finland 2021React Finland 2021
36 min
The Eternal Sunshine of the Zero Build Pipeline
For many years, we have migrated all our devtools to Node.js for the sake of simplicity: a common language (JS/TS), a large ecosystem (NPM), and a powerful engine. In the meantime, we moved a lot of computation tasks to the client-side thanks to PWA and JavaScript Hegemony.
So we made Webapps for years, developing with awesome reactive frameworks and bundling a lot of dependencies. We progressively moved from our simplicity to complex apps toolchains. We've become the new Java-like ecosystem. It sucks.
It's 2021, we've got a lot of new technologies to sustain our Users eXperience. It's time to have a break and rethink our tools rather than going faster and faster in the same direction. It's time to redesign the Developer eXperience. It's time for a bundle-free dev environment. It's time to embrace a new frontend building philosophy, still with our lovely JavaScript.
Introducing Snowpack, Vite, Astro, and other Bare Modules tools concepts!
Config Driven UI using ReactJS
React Summit 2023React Summit 2023
7 min
Config Driven UI using ReactJS
Top Content
Watch video: Config Driven UI using ReactJS
This lightning talk introduces config-driven UI in ReactJS, a technique for creating dynamic and customizable UIs without hard coding. It covers the implementation of different types of components and how they can be nested to create complex layouts.
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
React Summit 2022React Summit 2022
17 min
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
Top Content
Today's Talk discusses building flexible, resilient, and future-proof React components using composition and configuration approaches. The composition approach allows for flexibility without excessive conditional logic by using multiple components and passing props. The context API can be used for variant styling, allowing for appropriate styling and class specification. Adding variants and icons is made easy by consuming the variant context. The composition and configuration approaches can be combined for the best of both worlds.

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
High-performance Next.js
React Summit 2022React Summit 2022
50 min
High-performance Next.js
Workshop
Michele Riva
Michele Riva
Next.js is a compelling framework that makes many tasks effortless by providing many out-of-the-box solutions. But as soon as our app needs to scale, it is essential to maintain high performance without compromising maintenance and server costs. In this workshop, we will see how to analyze Next.js performances, resources usage, how to scale it, and how to make the right decisions while writing the application architecture.