React Suite Cascader ts:ItemDataType Prop
Last Updated :
28 Apr, 2025
React Suite is a front-end library of React components used to develop intermediate designs and back-end products. It helps developers provide a smooth development experience, with fewer efforts. In this article, we will learn about the Cascader component of the react suite with ItemDataType as the prop used.
The Cascader component is used to select the value with a hierarchical relationship between the data. The ts:ItemDataType prop helps select the list of items that are to be present under, the cascade hierarchical data. It is used under properties like data*, getChildren, onSelect, renderMenu, renderMenuItem, renderSearchItem, and renderValue. It is assigned in the form of an object, with various fields like label, value, and children, with nested components in it.
ts:ItemDataType Props:
- Value: It is the cascader hierarchical list, from which we have to select the required items.
- Label: This value is associated with the `labelKey`, and displays data similar to the Value.
- Children: It is an optional property of ItemDataType. It comprises child ItemDataTypes, of the Value or label.
- groupBy: It helps classify the Cascader into multiple similar groups.
- Loading: It is an optional property, and is used for components that have cascading relationships and lazy loading. E.g. Cascader, MultiCascader.
Syntax:
interface ItemDataType {
value: string;
label: ReactNode;
children?: ItemDataType[];
groupBy?: string;
loading?: boolean;
}
Setting Up React Application:
Step 1: Create a React.js application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e foldername, move into that directory using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the required module using the following command:
npm install rsuite
Project Structure: The project structure will look like this:
Example 1: In this example, we will use the Cascader component with an ItemDataType prop, where we will see what is the syntax of ts:ItemDataType. In variable name, data we are storing a list of names, in the form of an array. Each element in the array is an object, with 3 keys i.e. label, value, and children, and each of them is assigned the required value. Under the App function, we will use the Cascader tag, with a data prop assigned to it which is of type ItemData. In the output, we could see a drop-down with names in it.
- App.js: Write down the below code in the App.js file, where App is our default component provided by React in which code is being written.
JavaScript
import "rsuite/dist/rsuite.css";
import React from 'react'
import { Cascader } from 'rsuite';
const App = () => {
// Sample Options
const data = [
{
"label": "DSA",
"value": 1,
"children": [
{
"label": "Basic",
"value": 2
},
{
"label": "Advance",
"value": 3,
"children": [
{
"label": "DP",
"value": 4
},
{
"label": "Graph",
"value": 5
},
{
"label": "Fenwick Tree",
"value": 6
},
]
},
]
}
]
return (
<center>
<div style={{
display: 'block', width: 600, paddingLeft: 30
}}>
<h3>Geeks For Geeks</h3>
<h4>Cascader Component</h4>
<Cascader
style={{ width: 300 }}
placeholder="Select Your Favourite DSA Topic"
data={data}
/>
</div>
</center>
);
}
export default App;
Steps to run the program: To run the application execute the below command from the root directory of the project:
npm start
Output: Your web application will be live on “http://localhost:3000”.Now, you will see the following output:
Example 2: In this example, we will use the Cascader component with an ItemDataType prop, where we will see the disabled option in ts:ItemDataType. In variable name, data we are storing a list of names, in the form of an array. Each element in the array is an object, with 3 keys i.e. label, value, and children, and each of them is assigned the required value. Under the App function, we will use two cascader tags, the first is disabled with the disabled keyword, and the second is the default cascade list with data prop assigned to it which is of type ItemData. In the output, we could see a drop-down with names in it.
- App.js: Write down the below code in the App.js file, where App is our default component provided by React in which code is being written.
JavaScript
import "rsuite/dist/rsuite.css";
import React from 'react'
import { Cascader } from 'rsuite';
const App = () => {
// Sample Options
const data = [
{
"label": "DSA",
"value": 1,
"children": [
{
"label": "Basic",
"value": 2
},
{
"label": "Advance",
"value": 3,
"children": [
{
"label": "DP",
"value": 4
},
{
"label": "Graph",
"value": 5
},
{
"label": "Fenwick Tree",
"value": 6
},
]
},
]
}
]
return (
<center>
<div style={{
display: 'block', width: 600, paddingLeft: 30
}}>
<h3>Geeks For Geeks</h3>
<h4>Cascader Component</h4>
<Cascader disabled
style={{ width: 300 }}
placeholder="Select Your Favourite DSA Topic"
data={data}
/>
<Cascader
style={{ paddingTop: '23px', width: 300 }}
placeholder="Select Your Favourite DSA Topic"
data={data}
/>
</div>
</center>
);
}
export default App;
Steps to run the program: To run the application execute the below command from the root directory of the project:
npm start
Output: Your web application will be live on “http://localhost:3000”.Now, you will see the following output:
Reference: https://rsuitejs.com/components/cascader/#code-ts-item-data-type-code
Similar Reads
React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version
7 min read
React Fundamentals
React IntroductionReactJS is a component-based JavaScript library used to build dynamic and interactive user interfaces. It simplifies the creation of single-page applications (SPAs) with a focus on performance and maintainability. Why Use React?Before React, web development faced issues like slow DOM updates and mes
7 min read
React Environment SetupTo run any React application, we need to first setup a ReactJS Development Environment. In this article, we will show you a step-by-step guide to installing and configuring a working React development environment.Pre-requisite:We must have Nodejs installed on our PC. So, the very first step will be
3 min read
React JS ReactDOMReactDOM is a core React package that provides methods to interact with the Document Object Model, or DOM. This package allows developers to access and modify the DOM. It is a package in React that provides DOM-specific methods that can be used at the top level of a web app to enable an efficient wa
3 min read
React JSXJSX stands for JavaScript XML, and it is a special syntax used in React to simplify building user interfaces. JSX allows you to write HTML-like code directly inside JavaScript, enabling you to create UI components more efficiently. Although JSX looks like regular HTML, itâs actually a syntax extensi
5 min read
ReactJS Rendering ElementsIn this article we will learn about rendering elements in ReactJS, updating the rendered elements and will also discuss about how efficiently the elements are rendered.What are React Elements?React elements are the smallest building blocks of a React application. They are different from DOM elements
3 min read
React ListsIn lists, React makes it easier to render multiple elements dynamically from arrays or objects, ensuring efficient and reusable code. Since nearly 85% of React Projects involve displaying data collections- like user profiles, product catalogs, or tasks- understanding how to work with lists.To render
4 min read
React FormsForms are an essential part of any application used for collecting user data, processing payments, or handling authentication. React Forms are the components used to collect and manage the user inputs. These components include the input elements like text field, check box, date input, dropdowns etc.
5 min read
ReactJS KeysA key serves as a unique identifier in React, helping to track which items in a list have changed, been updated, or removed. It is particularly useful when dynamically creating components or when users modify the list. the When rendering a list, you need to assign a unique key prop to each element i
4 min read
Components in React
React ComponentsIn React, React components are independent, reusable building blocks in a React application that define what gets displayed on the UI. They accept inputs called props and return React elements describing the UI.In this article, we will explore the basics of React components, props, state, and render
4 min read
ReactJS Functional ComponentsIn ReactJS, functional components are a core part of building user interfaces. They are simple, lightweight, and powerful tools for rendering UI and handling logic. Functional components can accept props as input and return JSX that describes what the component should render.Stateless (before hooks)
5 min read
React Class ComponentsClass components are ES6 classes that extend React.Component. They allow state management and lifecycle methods for complex UI logic.Used for stateful components before Hooks.Support lifecycle methods for mounting, updating, and unmounting.The render() method in React class components returns JSX el
4 min read
ReactJS Pure ComponentsReactJS Pure Components are similar to regular class components but with a key optimization. They skip re-renders when the props and state remain the same. While class components are still supported in React, it's generally recommended to use functional components with hooks in new code for better p
4 min read
ReactJS Container and Presentational Pattern in ComponentsIn this article we will categorise the react components in two types depending on the pattern in which they are written in application and will learn briefly about these two categories. We will also discuss about alternatives to this pattern. Presentational and Container ComponentsThe type of compon
2 min read
ReactJS PropTypesIn ReactJS PropTypes are the property that is mainly shared between the parent components to the child components. It is used to solve the type validation problem. Since in the latest version of the React 19, PropeTypes has been removed. What is ReactJS PropTypes?PropTypes is a tool in React that he
5 min read
React Lifecycle In React, the lifecycle refers to the various stages a component goes through. These stages allow developers to run specific code at key moments, such as when the component is created, updated, or removed. By understanding the React lifecycle, you can better manage resources, side effects, and perfo
7 min read
React Hooks
Routing in React
Advanced React Concepts
React Projects