1- import React from "react"
1+ import React , { useEffect } from "react"
22import { Link } from "react-router-dom"
33import Prism from "prismjs"
44import lottie from "lottie-web"
@@ -15,13 +15,8 @@ import { ANIMATION_DATA } from "./animations"
1515
1616import "./styles.scss"
1717
18- export default class Home extends React . Component {
19- componentDidMount ( ) {
20- Prism . highlightAll ( )
21- this . loadAnimations ( )
22- }
23-
24- loadAnimations ( ) {
18+ export default function Home ( ) {
19+ const loadAnimations = ( ) => {
2520 ANIMATION_DATA . forEach ( data => {
2621 const name = data . title . toLowerCase ( )
2722
@@ -42,11 +37,18 @@ export default class Home extends React.Component {
4237 } , 1500 )
4338 }
4439
45- componentWillUnmount ( ) {
40+ const componentUnmountFunction = ( ) => {
4641 ANIMATION_DATA . forEach ( instance => instance . animation . destroy ( ) )
4742 }
4843
49- renderAnimations ( ) {
44+ useEffect ( ( ) => {
45+ Prism . highlightAll ( )
46+ loadAnimations ( )
47+
48+ return componentUnmountFunction
49+ } , [ ] )
50+
51+ const renderAnimations = ( ) => {
5052 return ANIMATION_DATA . map ( animation => {
5153 const animationName = animation . title . toLowerCase ( )
5254
@@ -63,81 +65,74 @@ export default class Home extends React.Component {
6365 } )
6466 }
6567
66- render ( ) {
67- return (
68- < div id = "home" >
69- < ScrollUpOnMount />
70-
71- { /*
72- * Title is set here _and_ in public/index.html...
73- * Doing so prevents title changes on other pages from persisting if a visitor return to the home page.
74- */ }
75- < SetMeta
76- title = "A modular, configuration-first front-end framework. No strings."
77- description = "Undernet is a highly customizable web framework for building websites."
78- />
79-
80- < div className = "medium-section fluid grid hero" >
81- < div className = "row" >
82- < div className = "xsmall-12 columns has-center-text" >
83- < PageHeader className = "h3" > { pkg . description } </ PageHeader >
84- </ div >
68+ return (
69+ < div id = "home" >
70+ < ScrollUpOnMount / >
71+
72+ { /*
73+ * Title is set here _and_ in public/index.html...
74+ * Doing so prevents title changes on other pages from
75+ * persisting if a visitor return to the home page.
76+ */ }
77+ < SetMeta
78+ title = "A modular, configuration-first front-end framework. No strings."
79+ description = "Undernet is a highly customizable web framework for building websites."
80+ />
81+
82+ < div className = "medium-section fluid grid hero" >
83+ < div className = "row" >
84+ < div className = "xsmall-12 columns has-center-text" >
85+ < PageHeader className = "h3" > { pkg . description } </ PageHeader >
86+ </ div >
8587
86- < div className = "xsmall-12 columns has-center-text" >
87- < Link to = { downloadPath } className = "medium button has-feather" >
88- Download < ChevronRight size = { 20 } role = "presentation" focusable = "false" />
89- </ Link >
90- < Link
91- to = { introductionPath }
92- className = "primary medium button has-gradient has-feather"
93- >
94- Learn More < ChevronRight size = { 20 } role = "presentation" focusable = "false" />
95- </ Link >
96- </ div >
88+ < div className = "xsmall-12 columns has-center-text" >
89+ < Link to = { downloadPath } className = "medium button has-feather" >
90+ Download < ChevronRight size = { 20 } role = "presentation" focusable = "false" />
91+ </ Link >
92+ < Link to = { introductionPath } className = "primary medium button has-gradient has-feather" >
93+ Learn More < ChevronRight size = { 20 } role = "presentation" focusable = "false" />
94+ </ Link >
95+ </ div >
9796
98- < div className = "xsmall-12 columns has-center-text" >
99- < p className = "un-version has-no-margin" > Version { pkg . version } </ p >
100- </ div >
97+ < div className = "xsmall-12 columns has-center-text" >
98+ < p className = "un-version has-no-margin" > Version { pkg . version } </ p >
99+ </ div >
101100
102- < div className = "xsmall-12 columns badges" >
103- < StatusBadges />
104- </ div >
101+ < div className = "xsmall-12 columns badges" >
102+ < StatusBadges />
105103 </ div >
106104 </ div >
105+ </ div >
107106
108- < div className = "medium-section fluid grid animations" >
109- < div className = "row has-no-padding" >
110- < div className = "column has-no-padding" >
111- < div className = "wide grid" >
112- < ul className = "row is-unstyled-list has-no-padding" > { this . renderAnimations ( ) } </ ul >
113- </ div >
107+ < div className = "medium-section fluid grid animations" >
108+ < div className = "row has-no-padding" >
109+ < div className = "column has-no-padding" >
110+ < div className = "wide grid" >
111+ < ul className = "row is-unstyled-list has-no-padding" > { renderAnimations ( ) } </ ul >
114112 </ div >
115113 </ div >
116114 </ div >
115+ </ div >
117116
118- < div className = "medium-section narrow grid" >
119- < div className = "row" >
120- < div className = "xsmall-12 columns has-center-text" >
121- < h2 className = "h6" > Painless Setup</ h2 >
122- < p > Install with npm:</ p >
123- < InstallNpm />
124- </ div >
125- < div className = "xsmall-12 columns has-center-text" >
126- < p > Or simply link to minified assets:</ p >
127- < InstallAssets />
128- </ div >
129- < div className = "xsmall-12 columns has-center-text" >
130- < p > See how Undernet can improve your developer experience!</ p >
131- < Link
132- to = { introductionPath }
133- className = "primary medium button has-gradient has-feather"
134- >
135- Learn More < ChevronRight size = { 20 } role = "presentation" focusable = "false" />
136- </ Link >
137- </ div >
117+ < div className = "medium-section narrow grid" >
118+ < div className = "row" >
119+ < div className = "xsmall-12 columns has-center-text" >
120+ < h2 className = "h6" > Painless Setup</ h2 >
121+ < p > Install with npm:</ p >
122+ < InstallNpm />
123+ </ div >
124+ < div className = "xsmall-12 columns has-center-text" >
125+ < p > Or simply link to minified assets:</ p >
126+ < InstallAssets />
127+ </ div >
128+ < div className = "xsmall-12 columns has-center-text" >
129+ < p > See how Undernet can improve your developer experience!</ p >
130+ < Link to = { introductionPath } className = "primary medium button has-gradient has-feather" >
131+ Learn More < ChevronRight size = { 20 } role = "presentation" focusable = "false" />
132+ </ Link >
138133 </ div >
139134 </ div >
140135 </ div >
141- )
142- }
136+ </ div >
137+ )
143138}
0 commit comments