I’m trying to improve my react skills, so i created this GIF meme component and it runs ok on the FCC platform but when i try to run it on codepen or repl it throws the syntax error unexpected token ‘<’, any help?
(my GIF variable doesn’t have a “>” tag only here (the forum here treats it as an actual image)
var GIF = <img src="https://i.makeagif.com/media/5-21-2019/ZftErB.gif" /
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
gifs: [],
counter: 0
}
this.button_click = this.button_click.bind(this);
this.button_reset = this.button_reset.bind(this)
}
button_click() {
if (this.state.counter <= 25) {
this.setState(state => ({
gifs : state.gifs.concat(GIF),
counter: state.counter+1
}));
}
else window.alert("reached maximum clicks")
}
button_reset() {
this.setState({
gifs: [],
counter: 0
})
}
render() {
return (<div> <button onClick={this.button_click}>
Click To Add GIF</button>
<button onClick={this.button_reset}>Click To Reset</button>
{this.state.gifs}
</div>)
}
}
ReactDOM.render(<MyComponent />, document)