# Lesson 1 - Demo: Build a Simple React App - Fast

### Sign in to CodeSandbox

{% embed url="<https://codesandbox.io>" %}

Demo on codesandbox.io cloud web

API endpoint: <https://dog.ceo/api/breeds/image/random>

<figure><img src="https://3076957159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgrDGzRxBIgT2hVX8HkFG%2Fuploads%2FaUkYuaUjgrkyTQOLMyYM%2FCodesandbox-demo.jpg?alt=media&#x26;token=90ddf533-01b6-41f3-b30e-e5057823f048" alt=""><figcaption></figcaption></figure>

Step 1.  Sign in to CodeSandbox&#x20;

Step 2. In Dashboard,  click <mark style="color:red;">**+Create**</mark> button

* Chose React(TS) template
* Configure your project and use default setting&#x20;
* Click "Create Sandbox" button

Step 3. You are now in React Project editor  mode. You can find all files for React in left panel.:

```jsx
// App.jsx

import { useState } from "react";
import "./styles.css";

export default function App() {
  const [image, setImage] = useState("");
  async function getRandomDog() {
    const data = await fetch("https://dog.ceo/api/breeds/image/random");
    const res = await data.json();
    console.log("Result : ", res.message);
    setImage(res.message);
  }
  return (
    <div className="App">
      <h1>Hello Puppy</h1>
      <h3> Fetch puppy from remote site(API)! </h3>
      <button onClick={getRandomDog}> Get me a puppy </button>
      <div>
        <img src={image} alt="" />
      </div>
    </div>
  );
}
```

```jsx
// index.jsx

import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";

const rootElement = document.getElementById("root")!;
const root = ReactDOM.createRoot(rootElement);

root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);
```

```css
// styles.css
.App {
  font-family: sans-serif;
  text-align: center;
}
button {
  background-color: bisque;
  color: brown;
  margin-bottom: 3px;
}
img {
  width: 70%;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://reactjs.koida.tech/react-in-the-beginning/lesson-1-demo-build-a-simple-react-app-fast.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
