---
id: "6e8a9370-4e26-40b8-b046-9e1d36d70cca"
name: react-select-creatable-preset-custom-split-1ca83e649300
description: "Implement a react-hook-form Controller with React-Select Creatable to separate selected options into 'preset' and 'custom' arrays, handling creation and removal logic within the onChange handler."
version: "0.1.0"
tags:
  - "react"
  - "react-hook-form"
  - "react-select"
  - "form-logic"
  - "data-transformation"
triggers:
  - "react-select creatable split preset custom"
  - "react-hook-form controller separate default and new options"
  - "react-select output structure preset custom array"
  - "handle removal in onChange react-select creatable"
---

# React-Select Creatable Preset/Custom Split

Implement a react-hook-form Controller with React-Select Creatable to separate selected options into 'preset' and 'custom' arrays, handling creation and removal logic within the onChange handler.

## Prompt

# Role & Objective
Act as a React Frontend Engineer. Your task is to implement a form field using `react-hook-form` and `react-select` (Creatable) that separates selected values into two distinct arrays: `preset` (default options) and `custom` (user-created options).

# Operational Rules & Constraints
1. Use the `Controller` component from `react-hook-form` to wrap the select component.
2. Use the `Creatable` feature from `react-select`.
3. The form value must be an object with the structure: `{ preset: [...], custom: [...] }`.
4. Implement logic to distinguish between default options and user-created options to populate the correct array.
5. Handle the creation of new options by adding them to the `custom` array.
6. Handle the removal of options within the `onChange` handler. Do not rely on non-existent props like `onRemoveOption`. Ensure removal updates the correct array (`preset` or `custom`).
7. The `value` prop for the Select component should be a concatenation of the `preset` and `custom` arrays.

# Anti-Patterns
- Do not use props that do not exist in the library (e.g., `onRemoveOption`).
- Do not mix preset and custom options in a single array in the final output.

## Triggers

- react-select creatable split preset custom
- react-hook-form controller separate default and new options
- react-select output structure preset custom array
- handle removal in onChange react-select creatable


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Development & Engineering, Product Management
Roles: Frontend Developer, Product Manager
Specialties: Cross Platform, React
Tools: React Hook Form, React Select
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 8856357d11d04177d5743e51184f0e8fe1a71dec7a581fb939d3d61a76c66332
