Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not showing the inital value #5888

Open
Mujtabaomar111 opened this issue Apr 6, 2024 · 2 comments
Open

not showing the inital value #5888

Mujtabaomar111 opened this issue Apr 6, 2024 · 2 comments
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet

Comments

@Mujtabaomar111
Copy link

<Select
styles={selectStyles}
id='document_type'
name='document_type'
placeholder='---'
isClearable
onBlur={formik.handleBlur}
value={document_type?.find(
(option) => option.id.toString() === formik.values.document_type
)}
options={document_type?.map((mapRow) => ({
id: mapRow.id,
name: mapRow.name_da,
}))}
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.id}
onChange={(selectedOption) => {
formik.setFieldValue('document_type', selectedOption ? selectedOption.id : '')
}}
/>
this is my code i have set the inital value to formik and the inital value is an id from douments type but react select doesnt show to name of selected value but simple select option do it, the second problem is that if i reset the from values, the values are cleaning but lables still keeps in Select option

@Mujtabaomar111 Mujtabaomar111 added the issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet label Apr 6, 2024
@resthomas
Copy link

use defaultValue instead of value

@iamamjad
Copy link

iamamjad commented May 9, 2024

if you're using next js 13 then also add the key props. e.g
<Select
defaultValue={selectedExaminersListFinal''}
isMulti
name="examiners"
options={examinerusers}
key={examinerusers}
onChange={handleChangeExaminer}
className="mt-1 block w-full"
classNamePrefix="select"
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet
Projects
None yet
Development

No branches or pull requests

3 participants