mirror of https://gitlab.com/ecentrics/concordia
Apostolos Fanakis
4 years ago
7 changed files with 83 additions and 92 deletions
@ -1,31 +1,34 @@ |
|||
import React, { |
|||
useContext, useEffect, useMemo, useState, |
|||
memo, useEffect, useMemo, useState, |
|||
} from 'react'; |
|||
import { Container } from 'semantic-ui-react'; |
|||
import { useSelector } from 'react-redux'; |
|||
import AppContext from '../../components/AppContext'; |
|||
import Board from './Board'; |
|||
import './styles.css'; |
|||
import { drizzle } from '../../redux/store'; |
|||
|
|||
const { contracts: { Forum: { methods: { getNumberOfTopics } } } } = drizzle; |
|||
|
|||
const Home = () => { |
|||
const { drizzle: { contracts: { Forum: { methods: { getNumberOfTopics } } } } } = useContext(AppContext.Context); |
|||
const [numberOfTopicsCallHash, setNumberOfTopicsCallHash] = useState(''); |
|||
const getNumberOfTopicsResults = useSelector((state) => state.contracts.Forum.getNumberOfTopics); |
|||
|
|||
useEffect(() => { |
|||
setNumberOfTopicsCallHash(getNumberOfTopics.cacheCall()); |
|||
}, [getNumberOfTopics]); |
|||
}, []); |
|||
|
|||
const numberOfTopics = useMemo(() => (getNumberOfTopicsResults[numberOfTopicsCallHash] !== undefined |
|||
? parseInt(getNumberOfTopicsResults[numberOfTopicsCallHash].value, 10) |
|||
: null), |
|||
[getNumberOfTopicsResults, numberOfTopicsCallHash]); |
|||
|
|||
return ( |
|||
return useMemo(() => ( |
|||
<Container id="home-container" textAlign="center"> |
|||
{numberOfTopics !== null && <Board numberOfTopics={numberOfTopics} />} |
|||
</Container> |
|||
); |
|||
), [numberOfTopics]); |
|||
}; |
|||
|
|||
export default Home; |
|||
Home.whyDidYouRender = true; |
|||
|
|||
export default memo(Home); |
|||
|
Loading…
Reference in new issue