import React, { Component } from 'react' import "./flash.css" import { ARTISTS } from "site/projects/museum/constants" export default class Flash extends Component { constructor(props) { super(props) this.state = { flashing: false, artist_name: "", } } componentDidUpdate(prevProps) { if (this.props.location.pathname !== prevProps.location.pathname) { this.flash() } } flash() { const { page_name } = this.props.match.params const artist_name = page_name.split('-')[0] if (!(artist_name in ARTISTS)) { return } if (artist_name !== this.state.artist_name) { this.setState({ flashing: true, artist_name }) setTimeout(() => { this.setState({ flashing: false }) }, 100) } } render() { if (!this.state.flashing) return null return (
) } }