csv export in react

JavaScript
import { CSVLink } from "react-csv";
<div>
{this.state.data != null ? (
              <CSVLink
                data={this.state.data}
                filename="data.csv"
                className="hidden"
                target="_blank"
              >
                <button
                  onClick={() => this.fetchData)}>
                  CSV Convert
                </button>
              </CSVLink>
            ) : null}
</div>
Source

Also in JavaScript: