diff --git a/src/components/Blog.js b/src/components/Blog.js index 6b20f79..3237b70 100644 --- a/src/components/Blog.js +++ b/src/components/Blog.js @@ -1,24 +1,32 @@ import { getDevtoArticle, getMediumArticle } from "article-api"; import moment from "moment"; -import { useEffect, useState } from "react"; +import { Fragment, useEffect, useState } from "react"; import { CgHashtag } from 'react-icons/cg'; import { useSelector } from "react-redux"; import config from "../config"; import { ga, skeleton } from "../helpers/utils"; import LazyImage from "./LazyImage"; +const displaySection = () => { + if ( + typeof config.blog !== 'undefined' && + typeof config.blog.source !== 'undefined' && + typeof config.blog.username !== 'undefined' && + config.blog.source && + config.blog.username + ) { + return true; + } else { + return false; + } +} + const Blog = () => { const [articles, setArticles] = useState(null); const loading = useSelector(state => state.loading); useEffect(() => { - if ( - typeof config.blog !== 'undefined' && - typeof config.blog.source !== 'undefined' && - typeof config.blog.username !== 'undefined' && - config.blog.source && - config.blog.username - ) { + if (displaySection()) { if (config.blog.source === 'medium') { getMediumArticle({ user: config.blog.username @@ -149,34 +157,40 @@ const Blog = () => { } return ( -