Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
react-selectize
Advanced tools
A Stateless & Flexible Select component for React inspired by Selectize
ReactSelectize
is a stateless Select component for ReactJS, that provides a platform for the more developer friendly SimpleSelect
& MultiSelect
components.
Both SimpleSelect
& MultiSelect
have been designed to work as drop in replacement for the built-in React.DOM.Select
component.
styles & features inspired by React Select & Selectize.
DEMO / Examples: furqanZafar.github.io/react-selectize
npm install react-selectize
{create-factory}:React = require \react
{SimpleSelect, MultiSelect, ReactSelectize} = require \react-selectize
SimpleSelect = create-factory SimpleSelect
MultiSelect = create-factory MultiSelect
.
.
.
SimpleSelect do
placeholder: 'Select a fruit'
options: <[apple mango orange banana]> |> map ~> label: it, value: it
on-value-change: (value, callback) ~>
alert value
callback!
.
.
.
MultiSelect do
placeholder: 'Select fruits'
options: <[apple mango orange banana]> |> map ~> label: it, value: it
on-values-change: (values, callback) ~>
alert values
callback!
React = require("react");
ReactSelectize = require("react-selectize");
SimpleSelect = ReactSelectize.SimpleSelect;
MultiSelect = ReactSelectize.MultiSelect;
.
.
.
<SimpleSelect
placeholder = "Select a fruit"
onValueChange = {function(value, callback){
alert(value);
callback();
}}
>
<option value = "apple">apple</option>
<option value = "mango">mango</option>
<option value = "orange">orange</option>
<option value = "banana">banana</option>
</SimpleSelect>
.
.
.
// Note: options can be passed as props as well, for example
<MultiSelect
placeholder = "Select fruits"
options = ["apple", "mango", "orange", "banana"].map(function(fruit){
return {label: fruit, value: fruit};
});
onValuesChange = {function(values, callback){
alert(values);
callback();
}}
/>
to include the default styles add the following import statement to your stylus file:
@import 'node_modules/react-selectize/src/index.css'
the default structure of an option object is {label: String, value :: a}
where a
implies that value
property can be of any equatable type
SimpleSelect notifies change via onValueChange
prop whereas MultiSelect notifies change via onValuesChange
prop
the onValueChange callback for SimpleSelect is passed 2 parameters. the selected option object
(instead of the value property of the option object) and a callback
the onValuesChange callback for MultiSelect is passed 2 parameters an Array of selected option objects (instead of a collection of the value properties or a comma separated string of value properties) and a callback
all the on*Change
functions receive a callback as the final parameter, which MUST always be invoked, for example when using state for the value
prop of SimpleSelect
the onValueChange
callback implementation would look like this:
value = {{label: "apple", value: "apple"}}
onValueChange = {function(value, callback){
self.setState(value, callback);
}}
when relying on the components internal state for managing the value:
onValueChange = {function(value, callback){
console.log(value);
callback(); // must invoke callback
}}
uid
function which accepts an option object and returns a unique id, for example:// assuming the type of our option object is:
// {firstName :: String, lastName :: String, age :: Int}
uid = {function(item){
return item.firstName + item.lastName;
}}
the uid
function is used internally for performance optimization.
npm install
gulp
localhost:8000
npm test
, npm run coverage
for unit tests & coverageMINIFY=true gulp
v0.4.0 / 21st January 2016
delimiters
& valuesFromPaste
(#21)FAQs
A Stateless & Flexible Select component for React inspired by Selectize
The npm package react-selectize receives a total of 9,981 weekly downloads. As such, react-selectize popularity was classified as popular.
We found that react-selectize 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.