- First of all, I'm sorry because I'm not very good at English
- I used the DropDown component at reactstrap and it had a bit of a problem, compoent not get select value and after solving that problem i want to share how i solved it.
- Thank you for your interest.
import React, { useState } from 'react'
import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap'
const MyExample = () => {
const toggle = () => setDropdownOpen(prevState => !prevState)
const [dropdownOpen, setDropdownOpen] = useState(false)
const [itemDropDown, setItemDropDown] = useState('DropDown')
const itemsCourseType = ['Item1', 'Item2', 'Item3', 'Item4']
const getItemsDropDown= items => {setItemDropDown(items)}
return (
<div>
<Dropdown isOpen={dropdownOpen} toggle={toggle}>
<DropdownToggle caret>
{courseType}
</DropdownToggle>
<DropdownMenu>
{itemsCourseType.map((item, id) => (
<DropdownItem onClick={() => getItemsDropDown(item)}>
{itemDropDown}
</DropdownItem>
))}
</DropdownMenu>
</Dropdown>
</div>
export default MyExample
Comments
Post a Comment