diff --git a/blog_images/react-selected-option.jpg b/blog_images/react-selected-option.jpg new file mode 100644 index 000000000..f3dff693e Binary files /dev/null and b/blog_images/react-selected-option.jpg differ diff --git a/blog_posts/react-selected-option.md b/blog_posts/react-selected-option.md new file mode 100644 index 000000000..aaffa3ac8 --- /dev/null +++ b/blog_posts/react-selected-option.md @@ -0,0 +1,61 @@ +--- +title: How can I set the value of a select input in React? +type: question +tags: react,components,input +authors: maciv +cover: blog_images/react-selected-option.jpg +excerpt: Learn of all the different ways to set the value of a selected input in React with this quick guide. +--- + +**Adding selected to an option** + +A very common way of setting a ` callback(value)} + > + {values.map(([value, text]) => ( + + ))} + + ); +} +``` + +**Setting value for the select** + +While this approach closely resembles HTML and feels intuitive, there is an easier way to do the same thing. [React](https://reactjs.org/docs/forms.html#the-select-tag) provides us with a shared API between ``, `