So I'm using React to create a web app and I'm just working with only js files and css files, no html. I have a js file like this with some html code and some js code:
class Teams extends Component {
state = {
teams: []
}
componentDidMount() {
...
}
abc = () => {
...
};
render() {
return (
<Container>
<Row className="space"></Row>
<br></br>
<br></br>
<Row className="about-row"><h3>Teams</h3></Row>
<br></br>
<br></br>
<Row className="about text-center">
{
this.abc()
}
</Row>
</Container>
);
}
}
export default Teams;
Basically I was wondering if there was a way to insert js code between html tags; I.e. Is there a way to do something like this:
<div>
//js code
let x = "hello";
console.log(x);
</div>
I've tried using html script tags and inserting js code in between but it doesn't work. Would I have to make a function outside the html tags and just call that function from inside the tags?