React: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 7: | Line 7: | ||
); | ); | ||
</source> | </source> | ||
=Run= | |||
=Maps= | =Maps= | ||
Line 19: | Line 21: | ||
</li> | </li> | ||
);</source> | );</source> | ||
=Component Example= | |||
<source lang="babel" line="line"> | |||
import React, {Component} from 'react'; | |||
import ReactDOM from 'react-dom'; | |||
class Parent extends React.Component { | |||
render() { | |||
return <div></div>; | |||
} | |||
};</source> |
Revision as of 05:55, 23 October 2019
Quick Reference
Variables
const myVar = (
<h1>Love it</h1>
);
Run
Maps
// Only do this if items have no stable IDs
const todo = ["fix", "syntax", "highlighting"];
const todoItems = todos.map((todo, index) =>
<li key={index}>
{todo.text}
</li>
);
Component Example
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
class Parent extends React.Component {
render() {
return <div></div>;
}
};