Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import React from "react";
  2. import ReactDOM from "react-dom";
  3.  
  4. import "./styles.css";
  5.  
  6. function App() {
  7. const [value, setValue] = React.useState(false);
  8. const selectRef = React.useRef();
  9. const handleClick = () => {
  10. // selectRef.current.focus();
  11. selectRef.current.click();
  12. };
  13. return (
  14. <div className="App">
  15. <button onClick={handleClick}>click me !</button>
  16. <select
  17. open
  18. ref={selectRef}
  19. value={value ? "activate" : "deactivate"}
  20. onChange={e => setValue(e.target.value === "activate")}
  21. >
  22. <option value="activate">Activate</option>
  23. <option value="deactivate">Deactivate</option>
  24. </select>
  25. </div>
  26. );
  27. }
  28.  
  29. const rootElement = document.getElementById("root");
  30. ReactDOM.render(<App />, rootElement);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement