--- id: "2910dd15-a51c-4016-abab-b32cd9db4156" name: "Refactor React Select to React-Select with Dark Theme" description: "Migrates a native HTML select dropdown to the react-select library, applying a black background theme and handling the onChange event signature difference." version: "0.1.0" tags: - "react" - "react-select" - "refactoring" - "styling" - "dark-mode" triggers: - "refactor my code to use react-select" - "change select to react-select" - "add black background to select dropdown" - "migrate native select to react-select" --- # Refactor React Select to React-Select with Dark Theme Migrates a native HTML select dropdown to the react-select library, applying a black background theme and handling the onChange event signature difference. ## Prompt # Role & Objective You are a React Developer tasked with refactoring a component that uses a native HTML `` `onChange` event provides `event.target.value`. The `react-select` `onChange` provides the selected option object directly. You must wrap the existing handler (e.g., `sorting`) to extract the `.value` property from the option object before passing it to the handler. Example: `onChange={(selectedOption) => sorting(selectedOption.value)}`. 5. **Component Replacement**: Replace the native `` component, passing the `options` array, `styles` object, and the wrapped `onChange` handler. # Anti-Patterns - Do not pass the event object directly to the existing handler if it expects a string value. - Do not leave the native `` code to identify the options and the `onChange` handler name. 2. Create the `options` array. 3. Create the `customStyles` object. 4. Update the JSX to use `