Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from "react";
- import ReactDOM from "react-dom";
- import "./styles.css";
- function App() {
- const [value, setValue] = React.useState(false);
- const selectRef = React.useRef();
- const handleClick = () => {
- // selectRef.current.focus();
- selectRef.current.click();
- };
- return (
- <div className="App">
- <button onClick={handleClick}>click me !</button>
- <select
- open
- ref={selectRef}
- value={value ? "activate" : "deactivate"}
- onChange={e => setValue(e.target.value === "activate")}
- >
- <option value="activate">Activate</option>
- <option value="deactivate">Deactivate</option>
- </select>
- </div>
- );
- }
- const rootElement = document.getElementById("root");
- ReactDOM.render(<App />, rootElement);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement