'React onClick event not firing with express-react-views
I am using express-react-views
+ NodeJS
to make a media platform. My "like button" element is not firing it's onClick
event. My relevant code:
<h1>{this.state.title}</h1> 103 <button onClick = {this.like}>👍</button>
this.like = async (event) => {
event.preventDefault();
await axios({ method: "GET", url: "http://localhost:9037/test" });
};
Note: I don't need to get the data of the request.
What can I do to get it to work?
Solution 1:[1]
express-react-views
is static server-side capability. To call react code you have to include react client side.
See this issue about this behavior https://github.com/reactjs/express-react-views/issues/59
This example might do what you want https://github.com/reactjs/express-react-views/tree/master/examples/dynamic
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |