question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncontrolled select support?

See original GitHub issue

Hi, the defaultValue attribute for <select> does not work in preact: https://stackblitz.com/edit/preact-bug-defaultvalue-zn7r9a .

Switching to a selected attribute (in <option> ) seems to work but causes some strange behaviour on late renderings (no sandbox yet).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
andrewigginscommented, Aug 11, 2020

To be clear for anyone looking to work on this, defaultValue on <select> is not a DOM prop (MDN) but is something React supports, so support for defaultValue on <select> needs to be in preact/compat.

<option> does have a defaultSelected property (MDN), but not sure what React does with this.

0reactions
themrecommented, Nov 1, 2022

Hi, i just encountered this bug with defaultvalue on the select and i have a stackblitz example here: https://stackblitz.com/edit/preact-starter-template-yktscr?file=App.jsx. I used defaultValue on the select, but no luck. Or am I missing something?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncontrolled Components - React
In a controlled component, form data is handled by a React component. The alternative is uncontrolled components, where form data is handled by...
Read more >
A component is changing the uncontrolled value state of ...
It's considered controlled if the value is not undefined . The value for Select should be selected using the value ticket?.status when list ......
Read more >
Controlled vs. uncontrolled components in React
In this tutorial, we'll explain the difference between controlled and uncontrolled components in React with practical examples.
Read more >
Controlled & Uncontrolled Components in React - Opcito
An Uncontrolled component stores its own state internally, and we have to query the DOM with the help of a ref to find...
Read more >
Controlled vs Uncontrolled Components in React - ITNEXT
React supports two types of components: controlled components and uncontrolled components. The React docs state: In most cases, we recommend using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found