So I've been trying to access a parents state from a child component, however I keep getting either an error message or it doesn't work all together. I have found multiple solutions online, however none of them work for React with Typescript.
So here is an simplified code example of what I'm trying to do.
export default class parent extends React.Component {
state= {
exist: true
}
render() {
return (
<div>
<child>
<div>
)
}
export default class child extends React.Component {
componentDidMount = () => {
document.getElementById("theText").value = "It does exist!"
}
render() {
return (
<div>
<h1 id="theText">It Doesn't exist</h1>
<div>
)
}
PS// This is NOT the code I'm working on! I just quickly wrote it so it's easier to see what I'm trying to do!