react select with custom option
import React from "react";
import ReactDOM from "react-dom";
import Select from "react-select";
const options = [
{ value: "Abe", label: "Abe", customAbbreviation: "A" },
{ value: "John", label: "John", customAbbreviation: "J" },
{ value: "Dustin", label: "Dustin", customAbbreviation: "D" }
];
const formatOptionLabel = ({ value, label, customAbbreviation }) => (
<div style={{ display: "flex" }}>
<div>{label}</div>
<div style={{ marginLeft: "10px", color: "#ccc" }}>
{customAbbreviation}
</div>
</div>
);
const CustomControl = () => (
<Select
defaultValue={options[0]}
formatOptionLabel={formatOptionLabel}
options={options}
/>
);
ReactDOM.render(<CustomControl />, document.getElementById("root"));
Also in JavaScript:
- react start new app
- bitfield permissions discord,.js
- jquery get all classes of a div
- javascript add value to input
- js onclick open the phone application
- postmark with nodejs
- cypress memory leak
- js hash table example
- angular random number between 1 and 10
- javascript substring last character
- using aria attributes in angular
- javascript hasclass
- javascript linting
- freecodecamp cdn
- array matching
- vuejs take rgba values from coordinate
- javascript go to top of page
- discord.js send message to specific channel
- regular expression match text between quotes
- function in javascript
- example of while loop in javascript with array length
- form data-request octobercms
- create-react-app
- variable defaults javascript es6