'I can't figure out how to setup [HMR]
I am confused as to why my react.js code will not accept a fetch data to "https://hacker-news.firebaseio.com/v0/item/29042728.json?print=pretty". I keep getting the error "[HMR] Waiting for update signal from WDS"
My Component Code
//import './App.css';
class App extends React.Component {
// Constructor
constructor(props) {
super(props);
this.state = {
items: [],
DataisLoaded: false
};
}
// ComponentDidMount is used to
// execute the code
componentDidMount() {
fetch(
//if https://jsonplaceholder.typicode.com/users is used, then works
"https://hacker-news.firebaseio.com/v0/item/29042728.json?print=pretty")
.then((res) => res.json())
.then((json) => {
this.setState({
isLoaded:true,
items: json,
});
})
}
render() {
const { DataisLoaded, items } = this.state;
if (!DataisLoaded) return <div>
<h1> Pleses wait some time.... </h1> </div> ;
return (
<div className = "App">
<h1> Fetch data from an api in react </h1> {
items.map((item) => (
<ol key = { item.id } >
User_Name: { item.username },
Full_Name: { item.name },
User_Email: { item.email }
</ol>
))
}
</div>
);
}
}
export default App;
``
I tried to fix it by going to node_modules -> webpack -> hot folder, and editing the log.js file but it's still happening.
Thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
