
# 30 seconds of React
> Curated collection of useful React snippets that you can understand in 30 seconds or less.
#### Related projects
* [30 Seconds of Code](https://30secondsofcode.org)
* [30 Seconds of CSS](https://30-seconds.github.io/30-seconds-of-css/)
* [30 Seconds of Interviews](https://30secondsofinterviews.org/)
## Table of Contents
### Array
View contents
* [DataList](#datalist)
* [DataTable](#datatable)
* [MappedTable](#mappedtable)
View contents
* [Input](#input)
* [LimitedTextarea](#limitedtextarea)
* [PasswordRevealer](#passwordrevealer)
* [Select](#select)
* [TextArea](#textarea)
View contents
* [TreeView](#treeview)
View contents
* [AutoLink](#autolink)
View contents
* [Carousel](#carousel)
* [Collapse](#collapse)
* [FileDrop](#filedrop)
* [Mailto](#mailto)
* [ModalDialog](#modaldialog)
* [StarRating](#starrating)
* [Tab](#tab)
* [Ticker](#ticker)
* [Toggle](#toggle)
* [Tooltip](#tooltip)
| ID | Value |
|---|---|
| {i} | {val} |
| ` element. Use `Array.prototype.map` to render each object in the `filteredData` array as a ` | ||
|---|---|---|
` for each key in the object.
```jsx
function MappedTable({ data, propertyNames }) {
let filteredData = data.map(v =>
Object.keys(v)
.filter(k => propertyNames.includes(k))
.reduce((acc, key) => ((acc[key] = v[key]), acc), {})
);
return (
Examples```jsx const people = [ { name: 'John', surname: 'Smith', age: 42 }, { name: 'Adam', surname: 'Smith', gender: 'male' } ]; const propertyNames = ['name', 'surname', 'age']; ReactDOM.render([⬆ Back to top](#table-of-contents) ## Input ### Input Renders an `` element that uses a callback function to pass its value to the parent component. Use object destructuring to set defaults for certain attributes of the `` element. Render an `` element with the appropriate attributes and use the `callback` function in the `onChange` event to pass the value of the input to the parent. ```jsx function Input ({ callback, type = 'text', disabled = false, readOnly = false, placeholder = '' }) { return ( callback(value)} /> ); } ``` Examples```jsx ReactDOM.render( console.log(val)}/>, document.getElementById('root') ); ```[⬆ Back to top](#table-of-contents) ### LimitedTextarea Renders a textarea component with a character limit. Use the value of the `value` prop to determine the initial `state.content` and `state.characterCount` and the value of the `limit` props to determine the value of `state.limit`. Create a method, `handleChange`, which trims the `event.target.value` data if necessary and uses `Component.prototype.setState` to update `state.content` and `state.characterCount`, and bind it to the component's context. In the`render()` method, use a` ` to wrap both the` |