title: How to show and hide some columns on React Table?
body: <p>I have created a React Table. I want to hide or show some columns in my table by user action. By default all columns should be visible but we will have some check boxes to hide or show some columns.</p>
  
  <p><a href="https://i.stack.imgur.com/EfrqH.png" rel="noreferrer">Image of my table</a></p>
  
  <p>Suppose I want to show 4 of the 8 columns. Please suggest me an easy technique to achieve this.</p>
  
  <p>My Column Header Array is  </p>
  
  <pre><code>  const columns = [
    {
  Header: 'Column 1',
      columns: [
         {
             Header: 'S Column 1',
             accessor: 'firstName'
         }
    ]
      },
     {
    Header: 'Column 2',
     columns: [
       {
          Header: 'S Column 2',
          accessor: 'firstName'
        }
     ]
         },
       {
          Header: 'Column 3',
          columns: [
       {
          Header: 'S Column 3',
          accessor: 'firstName'
        }
       ]
       },
         {
        Header: 'Column 4',
        columns: [
          {
          Header: 'S column 4',
          accessor: 'firstName'
         }
        ]
         },
       {
   Header: 'Column 5',
  columns: [
       {
  Header: 'S column 5',
   accessor: 'firstName'
      }
     ]
    },
    {
   Header: 'Column 6',
   columns: [
   {
      Header: 'S column 6a',
      accessor: 'firstName'
    },
      {
      Header: 'S column 6b',
      accessor: 'firstName'
     },
     {
      Header: 'S column 6c',
      accessor: 'firstName'
       },
     {
       Header: 'S column 6d',
       accessor: 'firstName'
       }
    ]
      },
    {
   Header: 'Column 7',
   columns: [
   {
    Header: 'S column 7',
       accessor: 'firstName'
     }
       ]
      },
      {
      Header: 'Column 8',
      columns: [
    {
     Header: 'S Column 8a',
     accessor: 'firstName'
    },
   {
     Header: 'S Column 8b',
     accessor: 'firstName'
     },
     {
  Header: 'S Column 8c',
  accessor: 'firstName'
    },
    {
    Header: 'S Column 8d',
    accessor: 'firstName'
    }
   ]
    },
    ];
  </code></pre>
  
  <p>Please help me to achieve this feature by easiest technique.</p>
  
  <p>If you can, you can show a demo on codesandbox.</p>