Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/useDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React, { useState } from "react";

const useDropdown = (label, defaultState, options) => {
const [state, updateState] = useState(defaultState);
const id = `use-dropdown-${label.replace(" ", "").toLowerCase()}`;
// if the replace pattern is a string only the first occurrence will be replaced
// so to replace all use a regex with g flag
const id = `use-dropdown-${label.replace(/ /g, "").toLowerCase()}`;
const Dropdown = () => (
<label htmlFor={id}>
{label}
Expand Down