Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
rc-cascader
Advanced tools
The rc-cascader package is a React component for creating cascading drop-down menus. It allows users to select options from a hierarchical structure, which is useful for selecting nested categories or locations.
Basic Cascading Menu
This code sample demonstrates how to create a basic cascading menu with the rc-cascader package. The 'options' array defines the hierarchical structure of the menu, and the 'onChange' function logs the selected value.
import React from 'react';
import Cascader from 'rc-cascader';
const options = [
{
value: 'zhejiang',
label: 'Zhejiang',
children: [
{
value: 'hangzhou',
label: 'Hangzhou',
children: [
{
value: 'xihu',
label: 'West Lake',
},
],
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
children: [
{
value: 'nanjing',
label: 'Nanjing',
children: [
{
value: 'zhonghuamen',
label: 'Zhong Hua Men',
},
],
},
],
},
];
function onChange(value) {
console.log(value);
}
const App = () => (
<Cascader options={options} onChange={onChange} />
);
export default App;
Custom Trigger
This code sample shows how to use a custom trigger, such as a button, to open the cascading menu. The children of the Cascader component determine the trigger element.
import React from 'react';
import Cascader from 'rc-cascader';
const options = [/* ... */];
const App = () => (
<Cascader options={options}>
<button>Click me to select</button>
</Cascader>
);
export default App;
Search and Filter
This code sample illustrates how to enable a search and filter functionality within the cascading menu by setting the 'showSearch' prop to true. This allows users to quickly find options by typing.
import React from 'react';
import Cascader from 'rc-cascader';
const options = [/* ... */];
const App = () => (
<Cascader options={options} showSearch />
);
export default App;
React-select is a flexible and customizable select input component for React. It supports single and multi-select options, as well as asynchronous loading of options. Compared to rc-cascader, react-select offers more customization and is not specifically designed for cascading options.
Ant Design (antd) is a comprehensive UI design language and React UI library that includes a cascading menu component similar to rc-cascader. The Cascader component in antd is more integrated with the overall design system and may offer additional features and a more polished look.
React Cascader Component
IE 8+ ✔ | Chrome 31.0+ ✔ | Firefox 31.0+ ✔ | Opera 30.0+ ✔ | Safari 7.0+ ✔ |
npm install
npm start
http://react-component.github.io/cascader/
var Cascader = require('rc-cascader');
var React = require('react');
const addressOptions = [{
'label': '福建',
'value': 'fj',
'children': [{
'label': '福州',
'value': 'fuzhou',
'children': [{
'label': '马尾',
'value': 'mawei',
}],
}, {
'label': '泉州',
'value': 'quanzhou',
}],
}, {
'label': '浙江',
'value': 'zj',
'children': [{
'label': '杭州',
'value': 'hangzhou',
'children': [{
'label': '余杭',
'value': 'yuhang',
}],
}],
}, {
'label': '北京',
'value': 'bj',
'children': [{
'label': '朝阳区',
'value': 'chaoyang',
}, {
'label': '海淀区',
'value': 'haidian',
}],
}];
React.render(<Cascader options={options} />, container);
name | type | default | description |
---|---|---|---|
options | Object | The data options of cascade | |
value | Array | selected value | |
defaultValue | Array | initial selected value | |
onChange | Function(value, selectedOptions) | callback when finishing cascader select | |
onSelect | Function(selectedOptions, done) | callback when click any option, argument "done" use for async select | |
onVisibleChange | Function(visible) | callback when popup overlay's visibility changed | |
transitionName | String | transition className like "slide-up" | |
prefixCls | String | rc-cascader | prefix className of popup overlay |
popupClassName | String | additional className of popup overlay |
http://localhost:8000/tests/runner.html?coverage
rc-cascader is released under the MIT license.
0.1.0 / 2015-12-25
First release.
FAQs
cascade select ui component for react
The npm package rc-cascader receives a total of 1,197,312 weekly downloads. As such, rc-cascader popularity was classified as popular.
We found that rc-cascader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.