# Intro to JSX

## Basics

Consider the following:

```jsx
const element = <div>Hello World</div>;
```

It looks like a mix of javascript and HTML, and it is called JSX, which you will see a lot in React based applications. It contains an opening tag and a closing tag.

In React Native, the idea behind it the same, except the syntax might be slightly different:

<pre class="language-jsx"><code class="lang-jsx"><strong>import { Text } from 'react-native';
</strong>
const element = &#x3C;Text>Hello World&#x3C;/Text>;
</code></pre>

In this example, we declare a variable name and embed it inside the JSX element with curly brackets:

```jsx
import { Text } from 'react-native';

const name = "Justin";
const element = <Text>Hello {name}</Text>;
```

JSX can contain children:

```jsx
import { Text, View } from 'react-native';

const name = "Justin";

const element = (
    <View>
        <Text>Hello {name}</Text>
        <Text>Nice to meet you!</Text>
    <View>
);
```

## Components

Components are independent and reusable bits of code.

<pre class="language-jsx"><code class="lang-jsx">import { Text } from 'react-native';

const TestComponent = () => {
<strong>    const name = "Justin";
</strong><strong>
</strong>    return (
        &#x3C;View>
            &#x3C;Text>Hello {name}&#x3C;/Text>
        &#x3C;/View>
    );
}
</code></pre>
