Just started with ReactJS, and I'm looking for the most efficient code to display the array below in the table structure, as described in the rendering section. I use .map to iterate through users / buttons objects, but have not succeeded so far.
In my code sample below, I want to take an array of userData and display the content in separate lines (html table format), i.e.
Joe, Smith, [Click 1A], [Click2B] // 'Click XX' - these are buttons
Mary, Murphy, [Click 2A], [Click2B]
How can i achieve this?
thank
var MyButton = require('./mybutton.js');
var userData =[{
userButtons: [
[{user: [{ id: 1, lastName: 'Smith', firstName: 'Joe',
buttons: [
{button:[{ id:0, value: "Click 1A" enabled:1}]},
{button:[{ id:1, value: "Click 1B" enabled:1}]}
]
}]}],
[{user: [{ id: 1, lastName: 'Murphy', firstName: 'Mary',
buttons: [
{button:[{ id:0, value: "Click 2A" enabled:1}]},
{button:[{ id:1, value: "Click 2B" enabled:1}]}
]
}]
}]
]}];
var DisplayData = React.createClass({
render: function() {
}
}
});
React.render(
<DisplayData tArr = {userData} />
, document.getElementById('content')
);
var React = require('react');
module.exports = React.createClass({
render: function() {
return (
<button>{this.props.value}</button>
)
}
});
source
share