Update all snippets to new format
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
### MappedTable
|
||||
---
|
||||
title: MappedTable
|
||||
tags: array,object,intermediate
|
||||
---
|
||||
|
||||
Renders a table with rows dynamically created from an array of objects and a list of property names.
|
||||
|
||||
@ -7,6 +10,8 @@ Renders a table with rows dynamically created from an array of objects and a lis
|
||||
* Use `Array.prototype.map` to render each value in the `propertyNames` array as a `<th>` element.
|
||||
* Use `Array.prototype.map` to render each object in the `filteredData` array as a `<tr>` element, containing a `<td>` for each key in the object.
|
||||
|
||||
*This component does not work with nested objects and will break if there are nested objects inside any of the properties specified in `propertyNames`*
|
||||
|
||||
```jsx
|
||||
function MappedTable({ data, propertyNames }) {
|
||||
let filteredData = data.map(v =>
|
||||
@ -48,11 +53,3 @@ ReactDOM.render(
|
||||
document.getElementById('root')
|
||||
);
|
||||
```
|
||||
|
||||
#### Notes:
|
||||
|
||||
- This component does not work with nested objects and will break if there are nested objects inside any of the properties specified in `propertyNames`.
|
||||
|
||||
<!-- tags: array,object -->
|
||||
|
||||
<!-- expertise: 1 -->
|
||||
|
||||
Reference in New Issue
Block a user