import React, { useEffect } from "react" import { connect } from "react-redux" import { getHillaryData } from "../actions/index" import { getTrumpData } from "../actions/index" export function Post(props) { let { articles, articlesHillary, candidate, getHillaryData, getTrumpData } = props // Fetch tweets when user clicks on candidate's button useEffect(() => { if (candidate === 'Hillary Clinton') { getHillaryData() } else if (candidate === 'Donald Trump') { getTrumpData() } }, [candidate, getHillaryData, getTrumpData]) let cand = candidate === undefined ? 'Not set' : candidate return (
@{cand}
{el.created_at}
{el.text}
Hillary stream
{el.created_at}
{el.text}