mirror of
https://github.com/mue/mue.git
synced 2026-07-26 10:11:15 +02:00
refactor and fix some things
This commit is contained in:
@@ -18,13 +18,16 @@ export default class Favourite extends React.PureComponent {
|
||||
const url = document.getElementById('backgroundImage').style.backgroundImage.replace('url("', '').replace('")', '');
|
||||
const credit = document.getElementById('credit').textContent;
|
||||
const location = document.getElementById('location').textContent;
|
||||
|
||||
localStorage.setItem('favourite', JSON.stringify({ url: url, credit: credit, location: location }));
|
||||
this.setState({ favourited: <StarIcon onClick={() => this.favourite()} /> });
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (localStorage.getItem('favourite')) this.setState({ favourited: <StarIcon onClick={() => this.favourite()} /> });
|
||||
if (localStorage.getItem('favourite')) {
|
||||
this.setState({ favourited: <StarIcon onClick={() => this.favourite()} /> });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user