JSFiddle - React, Tailwind, and code Playground

HTML

<a href="#" class="flex">Flex On</a>

<a href="#" class="flexoff">Flex Off</a>

<ul class="js-flexnav">
    <li><a href="#">Menu Item</a></li>
    <li><a href="#">Another Item</a></li>
    <li><a href="#">Has submenu</a>
        <ul>
            <li><a>Item 1</a></li>
            <li><a href="#">Item 2</a></li>
            <li><a href="#">We have to go deeper</a>
                  <ul>
                      <li><a href="#">Ellen Page</a></li>
                      <li><a href="#">Lukas Haas</a></li>
                </ul>
            </li>
            <li><a href="#">Item 4</a></li>
        </ul>
    </li>
    <li><a>More Item</a></li>
</ul>
        

<div class="menu-button">Menu</div>

CSS

/* I just imported FlexNav's CSS here, nothing changed so ignore this */




/* Flexnav Base Styles */

.flexnav {
  -webkit-transition: none;
  -moz-transition: none;
  -ms-transition: none;
  transition: none;
  -webkit-transform-style: preserve-3d;
  overflow: hidden;
  margin: 0 auto;
  width: 100%;
  max-height: 0; }
  .flexnav.opacity {
    opacity: 0; }
  .flexnav.show {
    max-height: 2000px;
    opacity: 1;
    -webkit-transition: all .5s ease-in-out;
    -moz-transition: all .5s ease-in-out;
    -ms-transition: all .5s ease-in-out;
    transition: all .5s ease-in-out; }
  .flexnav.one-page {
    position: fixed;
    top: 50px;
    right: 5%;
    max-width: 200px; }
  .flexnav li {
    font-size: 100%;
    position: relative;
    overflow: hidden; }
  .flexnav li a {
    position: relative;
    display: block;
    padding: .96em;
    z-index: 2;
    overflow: hidden;
    color: #222222;
    background: #a6a6a2;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15); }
  .flexnav li ul {
    width: 100%; }
    .flexnav li ul li {
      font-size: 100%;
      position: relative;
      overflow: hidden; }
  .flexnav li ul.show li {
    overflow: visible; }
  .flexnav li ul li a {
    display: block;
    background: #b2b2af; }
  .flexnav ul li ul li a {
    background: #bfbfbc; }
  .flexnav ul li ul li ul li a {
    background: #cbcbc9; }
  .flexnav .touch-button {
    position: absolute;
    z-index: 999;
    top: 0;
    right: 0;
    width: 50px;
    height: 50px;
    display: inline-block;
    background: #acaca1;
    background: rgba(0, 0, 0, 0.075);
    text-align: center; }
    .flexnav .touch-button:hover {
      cursor: pointer; }
    .flexnav .touch-button .navicon {
      position: relative;
      top: 1.4em;
      font-size: 12px;
      color: #666; }

.menu-button {
  position: relative;
  display: block;
  padding: 1em;
  background: #a6a6a2;
  color: #222222;
  cursor: pointer;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2); }
  .menu-button.one-page...

JavaScript

function flexNavDestroy(){
    $('.touch-button').off('touchstart click').remove();
    $('.item-with-ul *').off('focus');
    
    // this is new
    $('.js-flexnav').removeClass('flexnav').find('ul').show();
}

$('.flex').click(function(){
    
    // this is new
    $('.js-flexnav').addClass('flexnav');
    
    flexNav = $("ul.flexnav").flexNav({
            'animationSpeed': '250',
            'transitionOpacity': true,
            'buttonSelector': '.menu-button',
            'hoverIntent': false
        });
});

$('.flexoff').click(flexNavDestroy);







/*
	FlexNav.js 1.2

	Created by Jason Weaver http://jasonweaver.name
	Released under http://unlicense.org/

//
*/


(function() {
  var $;

  $ = jQuery;

  $.fn.flexNav = function(options) {
    var $nav, breakpoint, resetMenu, resizer, selector, settings, showMenu;
    settings = $.extend({
      'animationSpeed': 250,
      'transitionOpacity': true,
      'buttonSelector': '.menu-button',
      'hoverIntent': false,
      'hoverIntentTimeout': 150
    }, options);
    $nav = $(this);
    $nav.addClass('with-js');
    if (settings.transitionOpacity === true) {
      $nav.addClass('opacity');
    }
    $nav.find("li").each(function() {
      if ($(this).has("ul").length) {
        return $(this).addClass("item-with-ul").find("ul").hide();
      }
    });
    if ($nav.data('breakpoint')) {
      breakpoint = $nav.data('breakpoint');
    }
    showMenu = function() {
      if ($nav.hasClass('lg-screen') === true) {
        if (settings.transitionOpacity === true) {
          return $(this).find('>ul').addClass('show').stop(true, true).animate({
            height: ["toggle", "swing"],
            opacity: "toggle"
          }, settings.animationSpeed);
        } else {
          return $(this).find('>ul').addClass('show').stop(true, true).animate({
            height: ["toggle", "swing"]
          }, settings.animationSpeed);
        }
      }
    };
    resetMenu = function() {
      if...