Skip to content

Commit 719122b

Browse files
React Basics
1 parent c5e5cb4 commit 719122b

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

react.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,37 @@ module.exports = {
395395
},
396396
],
397397
},
398-
};
398+
};
399+
400+
401+
402+
// BASICS
403+
404+
// use those import everytime! They are needed in all examples
405+
import React from "react";
406+
import ReactDOM from "react-dom";
407+
408+
409+
// write JSX elements just as HTML
410+
const h1 = <h1>React JS</h1>;
411+
412+
// define element attribute just as in HTML
413+
const a = <a href="#0">What a link!</a>;
414+
415+
// multiline element are possible using parenthesis ()
416+
const ah1 = (
417+
<a href="#0">
418+
<h1>
419+
What a big link!
420+
</h1>
421+
</a>
422+
);
423+
424+
// a JSX expression must have exactly one outermost element
425+
// good habit is to have a <div>, or <> (<React.Fragment>, <Fragment>) wrapping everything
426+
const blog = (
427+
<div>
428+
<h1>Main title</h1>
429+
<p>Subtitle</p>
430+
</div>
431+
);

0 commit comments

Comments
 (0)