> For the complete documentation index, see [llms.txt](https://bryan-guner.gitbook.io/my-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bryan-guner.gitbook.io/my-docs/mynotes/udemy-react-and-redux/jsx.md).

# JSX

## JSX (Section 1,2)

React project directory structure:

![](file:///C:/Users/bryan/AppData/Local/Temp/msohtmlclip1/01/clip_image002.png)

Start and stop application:

![](file:///C:/Users/bryan/AppData/Local/Temp/msohtmlclip1/01/clip_image004.png)

| **Starting file:** | `src/index.js` |
| ------------------ | -------------- |

Three components inside `src/index.js` file:

1\. Import React and ReactDom libraries

2\. Create a React component

3\. Take the react component and show it on the screen

<table data-header-hidden><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><pre><code>import React from "react";
</code></pre><pre><code>import ReactDOM from "react-dom";
</code></pre><pre><code> 
</code></pre><pre><code>const App = () => {
</code></pre><pre><code>  const buttonText = "Click Me!";
</code></pre><pre><code> 
</code></pre><pre><code>  return (
</code></pre><pre><code>    &#x3C;div>
</code></pre><pre><code>      &#x3C;label className="label" htmlFor="name">Enter name:&#x3C;/label>
</code></pre><pre><code>      &#x3C;input id="name" type="text" />
</code></pre><pre><code>      &#x3C;button style={{ backgroundColor: "blue", color: "white" }}>
</code></pre><pre><code>        {buttonText}
</code></pre><pre><code>      &#x3C;/button>
</code></pre><pre><code>    &#x3C;/div>
</code></pre><pre><code>  );
</code></pre><pre><code>};
</code></pre><pre><code> 
</code></pre><pre><code>ReactDOM.render(&#x3C;App />, document.querySelector("#root"));
</code></pre></td><td><img src="file:///C:/Users/bryan/AppData/Local/Temp/msohtmlclip1/01/clip_image005.png" alt=""></td></tr></tbody></table>

Note:

`document.querySelector("#root")` refers to element with id of “root” in file:

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><strong>public/index.html</strong></td></tr><tr><td><pre><code>&#x3C;body>  
</code></pre><pre><code>  &#x3C;div id="root">&#x3C;/div> 
</code></pre><pre><code>  …
</code></pre></td></tr></tbody></table>

### Module Systems <a href="#jsx-section1-2-modulesystems" id="jsx-section1-2-modulesystems"></a>

![](file:///C:/Users/bryan/AppData/Local/Temp/msohtmlclip1/01/clip_image006.png)

### What is a React Component

![](file:///C:/Users/bryan/AppData/Local/Temp/msohtmlclip1/01/clip_image008.png)

### What is JSX

![](file:///C:/Users/bryan/AppData/Local/Temp/msohtmlclip1/01/clip_image010.png)

![](file:///C:/Users/bryan/AppData/Local/Temp/msohtmlclip1/01/clip_image012.png)

![](file:///C:/Users/bryan/AppData/Local/Temp/msohtmlclip1/01/clip_image014.png)
