Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
react-functional-select
Advanced tools
This lightweight package delivers ultimate performance for complex dropdown/select web component scenarios - it effortlessy handles searching, scrolling and keying even when working with data sets numbering in the tens of thousandes. It is powered by react-window and styled-components. In addition, it is built entirely using React Hooks
and FunctionComponents
.
While raw performance and minimal package size were the primary objectives, it is built with an advanced API that should cover the vast majority of use-cases. The API's functionality was largely inspired by react-select, which is one of the most flexible and complete React component API's I have seen. Essentially, my aim was to narrow the API's focus down to critical/common/performance-centric areas - and then deliver an optimized solution with as few lines of code as I deemed reasonable.
# npm
npm i react-window react-styled-components react-functional-select
# Yarn
yarn add react-window react-styled-components react-functional-select
import { Select } from 'react-functional-select';
import { Card, CardHeader, CardBody, Container, SelectContainer } from './helpers/styled';
type CityOption = {
readonly id: number;
readonly city: string;
readonly state: string;
};
const _options: CityOption[] = [
{ id: 1, city: 'Austin', state: 'TX' },
{ id: 2, city: 'Denver', state: 'CO' },
{ id: 3, city: 'Chicago', state: 'IL' },
{ id: 4, city: 'Phoenix', state: 'AZ' },
{ id: 5, city: 'Houston', state: 'TX' },
];
const BasicProps: React.FC = () => {
const [isInvalid, setIsInvalid] = useState(false);
const [isDisabled, setIsDisabled] = useState(false);
const [isClearable, setIsClearable] = useState(true);
const [selectedOption, setSelectedOption] = useState<CityOption | null>(null);
const onOptionChange = useCallback((option: CityOption | null): void => {
setSelectedOption(option);
}, []);
const getOptionValue = useCallback((option: CityOption): number => (option.id), []);
const getOptionLabel = useCallback((option: CityOption): string => (`${option.city}, ${option.state}`), []);
useEffect(() => {
isDisabled && setIsInvalid(false);
}, [isDisabled]);
return (
<Container>
<Card>
<CardHeader>
{JSON.stringify(selectedOption || {})}
</CardHeader>
<CardBody>
<SelectContainer>
<Select
options={_options}
isInvalid={isInvalid}
isDisabled={isDisabled}
isClearable={isClearable}
onOptionChange={onOptionChange}
getOptionValue={getOptionValue}
getOptionLabel={getOptionLabel}
/>
</SelectContainer>
</CardBody>
</Card>
</Container>
);
};
FAQs
Micro-sized and micro-optimized select component for React.js
The npm package react-functional-select receives a total of 727 weekly downloads. As such, react-functional-select popularity was classified as not popular.
We found that react-functional-select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
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.