1.0.9 • Published 3 years ago

cm_plugin_dropdown v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React simple dropdown

Install

npm i cm_plugin_dropdown --save

Example

The dropdown takes two params :

list

This is the list of elements that you want in the dropdown

setValue

This is the function you want to trigger when an element is choose

import React from 'react';
import { Dropdown } from 'cm_plugin_dropdown';
import 'cm_plugin_dropdown/dist/index.css';

/**
	* @param {array} list Element array
	* @param {fonction} setValue Fonction
	*/
function departementsDropdown() {

    //retrieval and storage of the value of the chosen element in the dropdown
    const [department, setDepartment] = useState('')

    //each time the dropdown value changes, a console.log with the new value will be displayed
    useEffect(() => {
        console.log("You chose "+department+"!");
    }, [department])

    //list of departments that will appear in the dropdown
    const departmentsNames = ['Sales', 'Marketing', 'Engineering', 'Human Ressources', 'Legal']

    return (
        <Dropdown list={departmentsNames} setValue={setDepartment} />
    )
}

export default departementsDropdown
1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago