File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1
- import React from "react" ;
1
+ import React , { useEffect , useState } from "react" ;
2
2
import styled from "styled-components" ;
3
3
import { responsiveSize } from "styles/responsiveSize" ;
4
4
@@ -19,10 +19,21 @@ const StyledSpan = styled.span`
19
19
` ;
20
20
21
21
const Header : React . FC = ( ) => {
22
+ const [ currentWordIndex , setCurrentWordIndex ] = useState ( 0 ) ;
23
+ const words = [ "Lists" , "Knowledge" ] ;
24
+
25
+ useEffect ( ( ) => {
26
+ const intervalId = setInterval ( ( ) => {
27
+ setCurrentWordIndex ( ( prevIndex ) => ( prevIndex === 0 ? 1 : 0 ) ) ;
28
+ } , 3000 ) ;
29
+
30
+ return ( ) => clearInterval ( intervalId ) ;
31
+ } , [ ] ) ;
32
+
22
33
return (
23
34
< StyledHeader >
24
35
< StyledH1 >
25
- Community Curated < StyledSpan > Lists </ StyledSpan >
36
+ Community Curated < StyledSpan > { words [ currentWordIndex ] } </ StyledSpan >
26
37
</ StyledH1 >
27
38
</ StyledHeader >
28
39
) ;
You can’t perform that action at this time.
0 commit comments