refactor and fix some things

This commit is contained in:
David Ralph
2021-01-16 18:39:03 +00:00
parent 5c579ee0a2
commit 0a735384df
23 changed files with 122 additions and 117 deletions

View File

@@ -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() {