React: How to implement datatables from react, using data from server
React: How to implement datatables from react, using data from server

React DataTables implementation. I've looked online to try and figure out how to initialized a table if I'm calling a database. All I've seen are examples of hard coded data sets. ex const dataSet =[sample data]
constructor(props) {
super(props);
this.state = {
dataSet:[],
columns: [
{ title: "ID", dataSet: "ID" },
{ title: "First", dataSet: "first_name" },
{ title: "Last", dataSet: "last_name" },
{ title: "Email", dataSet: "email" },
{ title: "Phone", dataSet: "phone_number" },
{ title: "Location", dataSet: "location" }
],
};
}
componentDidMount() {
fetch("http://localhost:4000/dataSet/")
...
return (
<SAMPLETABLE columns={columns} data={dataSet}>
);
is this the correct way to set this up?
This discussion has been closed.
Answers
Can you add code to allow selection by row with this method?
This thread might help - it discusses ajax source Data with React.js.
Colin