im trying to make a react hook to copy a "snippet" of code that ill have created, but, how do I make that happen?
function About() {
const [copy, setcopy] = useState(document.getElementsByClassName(
document.getElementById("test")
))
return (
<div>
<h1 className="test">ABOUT PAGE</h1>
<input id="input" type="text"/>
<button id="copy">Copy</button>
</div>
)
}
export default About
Top comments (3)
So first of all in react we don't use id to interact with the elements, if you want to copy the user input of the input element you must do it the react way.
What would the react way be?
import React, { useState } from 'react'
function Snippets() {
return (
}
function Snippet() {
const [copy, useCopy] = useState(true)
const [snippet, setSnippet] = useState([
{
name: 'post 1',
text: 'sample post',
},
]);
}
export default Snippets
So by className?