tsx
64 lines
1.74 KB
| 1 | import React, { Component } from 'react'; |
| 2 | import { FormattedMessage } from 'react-intl'; |
| 3 | import Firebase from './Firebase'; |
| 4 | import app from 'firebase/app'; |
| 5 | |
| 6 | type AboutProps = { |
| 7 | firebase: Firebase | null |
| 8 | } |
| 9 | |
| 10 | type AboutState = { |
| 11 | contentMain: string, |
| 12 | contentSkills: string, |
| 13 | updatedAt: string |
| 14 | } |
| 15 | |
| 16 | class About extends Component<AboutProps, AboutState> { |
| 17 | |
| 18 | aboutRef: app.database.Reference | undefined; |
| 19 | |
| 20 | constructor(props: AboutProps) { |
| 21 | super(props); |
| 22 | this.aboutRef = this.props.firebase?.aboutRef(); |
| 23 | this.state = { |
| 24 | contentMain: "Loading ...", |
| 25 | contentSkills: "Loading ...", |
| 26 | updatedAt: "Loading ..." |
| 27 | } |
| 28 | } |
| 29 | UNSAFE_componentWillMount() { |
| 30 | this.aboutRef?.on('value', (snapshot) => { |
| 31 | let items = snapshot?.val(); |
| 32 | this.setState({ |
| 33 | contentMain: items.contentMain, |
| 34 | contentSkills: items.contentSkills, |
| 35 | updatedAt: items.updatedAt |
| 36 | }); |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | componentWillUnmount() { |
| 41 | this.aboutRef?.off(); |
| 42 | } |
| 43 | |
| 44 | render() { |
| 45 | return ( |
| 46 | <div> |
| 47 | <h1> |
| 48 | <FormattedMessage id="about.title" |
| 49 | defaultMessage="About" |
| 50 | description="About page title"/> |
| 51 | </h1> |
| 52 | <p style={{lineHeight: "150%"}}>{this.state.contentMain}</p> |
| 53 | <h2 style={{marginTop: 8}}> |
| 54 | <FormattedMessage id="about.skills" |
| 55 | defaultMessage="Skills" |
| 56 | description="About page skills"/> |
| 57 | </h2> |
| 58 | <p style={{lineHeight: "150%"}}>{this.state.contentSkills}</p> |
| 59 | </div> |
| 60 | ); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | export default About; |