JSFiddle - React, Tailwind, and code Playground

HTML

<div id="innerTwitter"></div>

JavaScript

var container = $("#innerTwitter");

function showTweets(tweets) {
    var tweetPs = $.map(tweets, function (t) {
        return $('<p></p>').text(t.text).hide();
    });
    
    container.append(tweetPs);
    tweetPs[0].show();
    
    var currentIndex = 0;
    
    var nextTweet = function () {
        var nextIndex = currentIndex == tweets.length - 1 ? 0 : currentIndex + 1;
        tweetPs[currentIndex].fadeOut(400, function () {
            tweetPs[nextIndex].fadeIn(400);
        });
        currentIndex = nextIndex;
    };
    
    setInterval(nextTweet, 2000);
}

showTweets([
    { text: "tweet1" },
    { text: "tweet2" },
    { text: "tweet3" },
    { text: "tweet4" },
    { text: "tweet5" },
]);