Hi im using react and have an array of strings
const themes = [
'light',
'dark',
'cupcake',
'bumblebee',
'emerald',
'corporate',
'synthwave',
'retro',
'cyberpunk',
'valentine',
'halloween',
'garden',
'forest',
'aqua',
'lofi',
'pastel',
'fantasy',
'wireframe',
'black',
'luxury',
'dracula',
'cmyk',
'autumn',
'business',
'acid',
'lemonade',
'night',
'coffee',
'winter',
]
What i'm doing is mapping over them like this
{themes.map((Theme) => (
<li
className={`${theme === Theme && 'btn-primary'} ${
input.includes(Theme) && "btn-primary"
}`}
key={Theme}
onClick={() => setTheme(`${Theme}`)}
>
<label>{Theme}</label>
</li>
))}
I have an input at the top with state
const [input, setInput] = useState('')
<input
type="text"
placeholder="Type here"
className="w-full max-w-xs py-3 mb-3 input input-bordered"
value={input}
onChange={(e) => setInput(e.target.value)}
/>
I tried to use the regular filter method but i can't find a way to just simply filter an array of strings and if the input matches or contains the letters of a single theme to just show that ?
{themes.filter(theme => theme.toLowerCase().includes(input.trim().toLowerCase()) => (Template...)}