import React, { useEffect, useState } from 'react'; import { useDispatch, useSelector, shallowEqual } from 'react-redux'; import { withRedux } from 'lib/redux'; import Column from 'components/column'; const rehydrateStore = () => { if (localStorage.getItem('triplebyte-react-spa') === null) { return null; } else { return JSON.parse(localStorage.getItem('triplebyte-react-spa')); } }; const IndexPage = () => { const [loaded, setLoaded] = useState(false); const dispatch = useDispatch(); const columns = useSelector(state => state.columns, shallowEqual); useEffect(() => { dispatch({ type: 'RESET', payload: rehydrateStore() }); setLoaded(true); }, []); if (!loaded) return null; return (
{columns.map((c, index, array) => ( ))}
) } export default withRedux(IndexPage);