Commit 81944cd0 authored by Svein Olav Styve's avatar Svein Olav Styve

#19 Add favorite save feedback

parent ad58e2b7
import React from 'react';
import '../style/FavoriteButton.css';
export default function FavoriteSection(props) {
return (
<div className="Button-container">
<button onClick={props.save}>Save as favorite</button>
<button onClick={props.open}>Open favourite</button>
</div>
);
export default class FavoriteSection extends React.Component {
constructor(props) {
super(props);
this.state = {showSaveFeedback: false};
this.save = this.save.bind(this);
}
save = (e) => {
this.props.save(e);
this.setState({
showSaveFeedback: true
});
this.timerID = setInterval(
() => {
this.setState({
showSaveFeedback: false
});
},
3500
);
}
render() {
return (
<div className="Button-container">
<button onClick={this.save}>Save as favorite</button>
<button onClick={this.props.open}>Open favourite</button>
<p> { (this.state.showSaveFeedback) && "Favorite saved!" } </p>
</div>
);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment