I am facing a issue with one of my app. I am new to the react. I am using a laravel and react together. My problem is i am fetching data from a api which is a laravel controller. But the result which is coming in a html format but rendering in react it breaking the html codes. i have used parsers like import parse from 'html-react-parser'; import renderHTML from 'react-render-html';
but both are not working and it stop my result data also.
export default class Notify extends Component {
state={
duelist:[]
}
componentDidMount() {
axios.get(`upcomingdues`)
.then(res => {
const duelist = res.data;
//console.log(res.data);
this.setState({ duelist });
})
}
render() {
const mystyle = {
height: "300px",
overflow: "hidden"
};
const mystyle1 = {
left: "0px",
bottom: "0px"
};
const mystyle2 = {
left: "0px",
width: "0px"
};
return (
<div>
<div className="tab-content">
<div className="tab-pane active show" id="topbar_notifications_notifications" role="tabpanel">
<div className="kt-notification kt-margin-t-10 kt-margin-b-10 kt-scroll ps"
data-scroll="true" data-height="300" data-mobile-height="200" style={mystyle}>
{this.state.duelist}
</div>
</div>
</div>
<div className="ps__rail-x" style={mystyle1}>
<div className="ps__thumb-x" tabindex="0" style={mystyle2}></div>
</div>
</div>
);
}
}
if (document.getElementById('notify')) {
ReactDOM.render(<Notify />, document.getElementById('notify'));
}