have a mistake in a articles.js
articles.js:
import React, {Component} from 'react';
import './index.css';
export default class Class extends Component {
constructor(props) {
super(props);
this.state = {
asd: "asd"
}
}
componentDidMount(){
this.df();
}
async df(){
let a = await fetch("http://localhost:8080/articles")
let content = await a.json();
alert(content)
this.setState(state=>{
asd:content.core
}
)
}
render() {
return (
<div>
<div id={"mainArticle"} dangerouslySetInnerHTML={{__html:this.state.asd}}>
</div>
<div>
</div>
<p></p>
</div>
);
}
}
I take a string in the df function that contains an html fork and pass it to setState asd
after that, this function is passed to componentDidMount, which will launch the function and change the value of asd
next, the value of asd is passed to the
dangerouslySetInnerHTML attribute, where the div should already output the html markup inside itself
terminal gives me mistake:
Expected an assignment or function call and instead saw an expression
what wrong?
i dont no what to do…