Showing posts with label react js. Show all posts
Showing posts with label react js. Show all posts

Monday, 25 December 2023

How to Make Dynamic Cascading Dropdown Box in React JS with PHP


Introduction


In this tutorial, we'll explore how to create a dynamic cascading dropdown box using React JS for the front end and PHP for the back end. Cascading dropdowns provide a user-friendly way to filter and select data based on choices made in previous dropdowns.


How to Make Dynamic Cascading Dropdown Box in React JS with PHP


Prerequisites


Before we dive into the tutorial, make sure you have the following installed:

  • Node.js and npm for React development
  • A code editor (e.g., Visual Studio Code, Sublime Text)
  • PHP and a web server (e.g., Apache)

MySQL Database for Cascading Dropdown box


Below you can find country_state_city table sql query. So you have to run this query in your local mysql database which will be used under this Dyanmic Dependent Select box in React.js tutorial.


--
-- Table structure for table `country_state_city`
--
CREATE TABLE `country_state_city` (
  `id` int NOT NULL AUTO_INCREMENT,
  `country` varchar(250) NOT NULL,
  `state` varchar(250) NOT NULL,
  `city` varchar(250) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1;

INSERT INTO `country_state_city` VALUES (1,'USA','New York','New York city'),(2,'USA','New York','Buffalo'),(3,'USA','New York','Albany'),(4,'USA','Alabama','Birmingham'),(5,'USA','Alabama','Montgomery'),(6,'USA','Alabama','Huntsville'),(7,'USA','California','Los Angeles'),(8,'USA','California','San Francisco'),(9,'USA','California','San Diego'),(10,'Canada','Ontario','Toronto'),(11,'Canada','Ontario','Ottawa'),(12,'Canada','British Columbia','Vancouver'),(13,'Canada','British Columbia','Victoria'),(14,'Australia','New South Wales','Sydney'),(15,'Australia','New South Wales','Newcastle'),(16,'Australia','Queensland','City of Brisbane'),(17,'Australia','Queensland','Gold Coast\r\n'),(18,'India','Delhi','New Delhi'),(19,'India','Gujarat','Ahmedabad'),(20,'India','Gujarat','Vadodara'),(21,'India','Maharashtra','Mumbai'),(22,'India','Maharashtra','Pune');





Create React App


Start by creating a new React application, so here in this tutorial, we have already describe step by step to install React JS Application under this React JS CRUD Application tutorial.

Create Dropdown Components


Build components for dynamic cascading dropdown. In this component we will build Country, State and City Select box and then convert into dynamic dependent cascading select box which you can seen below. Here we have make DynamicDropdown.jsx component under this src/Component directory.

src/Component/DynamicDropdown.jsx

import React, { useState, useEffect } from 'react'

function DynamicDropdown(){

	const [countries, setCountries] = useState([]);

	const [states, setStates] = useState([]);

	const [cities, setCities] = useState([]);

	const handleCountryChange = async (event) => {
		const selectedCountry = event.target.value;
		const response = await fetch(`http://localhost/tutorial/dynamic_dependent_dropdown_box/api/fetch.php?country=${selectedCountry}`);
		const data = await response.json();
		setStates(data);
		setCities([]);
	};

	const handleStateChange = async (event) => {
		const selectedState = event.target.value;
		const response = await fetch(`http://localhost/tutorial/dynamic_dependent_dropdown_box/api/fetch.php?state=${selectedState}`);
		const data = await response.json();
		setCities(data);
	};

	useEffect(() => {

		const fetchCountries = async () => {
			const response = await fetch('http://localhost/tutorial/dynamic_dependent_dropdown_box/api/fetch.php');

			const data = await response.json();

			setCountries(data);
		};

		fetchCountries();

	}, []);

	return (

		<div className="container">
            <h1 className="mt-5 mb-5 text-primary text-center"><b>Dynamic Dependent Dropdown Box in React.js</b></h1>

            <div className="card">
                <div className="card-header">Dynamic Dependent Dropdown Box in React.js</div>
                <div className="card-body">
                	<div className="mb-3">
                		<select className="form-select" onChange={handleCountryChange}>
                			<option value="">Select Country</option>
                			{
                				countries.map((country, index) => (
                					<option key={index} value={country.country}>{country.country}</option>
                				))
                			}
                		</select>
                	</div>
                	<div className="mb-3">
                		<select className="form-select" onChange={handleStateChange}>
                			<option value="">Select State</option>
                			{
                				states.map((state, index) => (
                					<option key={index} value={state.state}>{state.state}</option>
                				))
                			}
                		</select>
                	</div>
                	<div className="mb-3">
                		<select className="form-select">
                			<option value="">Select City</option>
                			{
                				cities.map((city, index) => (
                					<option key = {index} value={city.city}>{city.city}</option>
                				))
                			}
                		</select>
                	</div>
                </div>
            </div>
        </div>

	)

}

export default DynamicDropdown;





Below this you can find details description of above provided React JS Component code.


import React, { useState, useEffect } from 'react'


This line imports the necessary modules from the React library. It includes the useState and useEffect hooks, which are essential for managing state and performing side effects in functional components.


function DynamicDropdown() {


This declares a functional component named DynamicDropdown. Functional components are a type of React component that use JavaScript functions to define the behavior of the component.


const [countries, setCountries] = useState([]);
const [states, setStates] = useState([]);
const [cities, setCities] = useState([]);


These lines use the useState hook to create state variables (countries, states, and cities) and their corresponding setter functions. These states will store the data for countries, states, and cities selected by the user.


const handleCountryChange = async (event) => {
		const selectedCountry = event.target.value;
		const response = await fetch(`http://localhost/tutorial/dynamic_dependent_dropdown_box/api/fetch.php?country=${selectedCountry}`);
		const data = await response.json();
		setStates(data);
		setCities([]);
	};


This function (handleCountryChange) is an event handler that gets triggered when the value of the country dropdown changes. It fetches data from the server based on the selected country and updates the states state. It also resets the cities state to an empty array.


const handleStateChange = async (event) => {
		const selectedState = event.target.value;
		const response = await fetch(`http://localhost/tutorial/dynamic_dependent_dropdown_box/api/fetch.php?state=${selectedState}`);
		const data = await response.json();
		setCities(data);
	};


Similar to handleCountryChange, this function (handleStateChange) is an event handler triggered when the state dropdown value changes. It fetches data from the server based on the selected state and updates the cities state.


useEffect(() => {
		const fetchCountries = async () => {
			const response = await fetch('http://localhost/tutorial/dynamic_dependent_dropdown_box/api/fetch.php');
			const data = await response.json();
			setCountries(data);
		};

		fetchCountries();
	}, []);


The useEffect hook is used here to fetch the list of countries when the component mounts. It calls the fetchCountries function, which makes an asynchronous request to the server and updates the countries state.


return (
		<div className="container">
            <h1 className="mt-5 mb-5 text-primary text-center"><b>Dynamic Dependent Dropdown Box in React.js</b></h1>
            {/* ... */}
		</div>
	)


This is the JSX part of the component. It returns the structure of the component, including HTML elements and React components. The UI contains three dropdowns for selecting country, state, and city, and it includes the necessary event handlers (onChange) for each dropdown.


export default DynamicDropdown;


Finally, this exports the DynamicDropdown component as the default export from this module, making it available for use in other parts of the application.

In summary, this React component creates a dynamic dependent dropdown box where the options in the state and city dropdowns change based on the selected country and state, respectively. The data is fetched from a server using asynchronous requests, and the component uses the useState and useEffect hooks to manage and update its state.

Import Cascading Component in App.jsx

Now we want to import Cascading Component in main React JS Application file which you seen below.

src/App.jsx

import { useState } from 'react'
import 'bootstrap/dist/css/bootstrap.min.css'
/*import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'*/
import DynamicDropdown from './Component/DynamicDropdown'

function App() {
  

   return (
      
      <div>
         <DynamicDropdown />
      </div>

  )
}

export default App


Let's break down the provided App.jsx file code line by line:


import { useState } from 'react'


This line imports the useState hook from the React library. In this particular file, it seems unused, so you might consider removing it unless you plan to use state in this component.


import 'bootstrap/dist/css/bootstrap.min.css'


This line imports the Bootstrap CSS styles. Bootstrap is a popular front-end framework for building responsive and visually appealing web applications. The inclusion of this line suggests that the application may use Bootstrap styles for UI components.


import DynamicDropdown from './Component/DynamicDropdown'


This line imports the DynamicDropdown component from the specified file path. The DynamicDropdown component is likely the one you described in a previous section, responsible for rendering a dynamic dependent dropdown box.


return (
    <div>
      <DynamicDropdown />
    </div>
  )


This is the body of the App component. It returns JSX code, which represents the structure of the component. In this case, it renders a div that contains the DynamicDropdown component.

In summary, this App.jsx file appears to be a simple React application entry point. It imports the necessary dependencies, including the Bootstrap styles and the DynamicDropdown component, and renders the DynamicDropdown component within a div. This structure suggests that the main functionality or UI of the application is encapsulated within the DynamicDropdown component.

Setting Up PHP Backend


Create a new PHP file under api, fetch.php, to fetch data from the server.


<?php

//fetch.php

header("Access-Control-Allow-Origin:* ");
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: *");

$connect = new PDO("mysql:host=127.0.0.1;dbname=testing", "root", "password");

if(isset($_GET['country']))
{
	$query = "SELECT DISTINCT state FROM country_state_city WHERE country = ?";
	$statement = $connect->prepare($query);
	$statement->execute([$_GET['country']]);
	$states = $statement->fetchAll(PDO::FETCH_ASSOC);
	echo json_encode($states);
}
else if(isset($_GET['state']))
{
	$query = "SELECT DISTINCT city FROM country_state_city WHERE state = ?";
	$statement = $connect->prepare($query);
	$statement->execute([$_GET['state']]);
	$cities = $statement->fetchAll(PDO::FETCH_ASSOC);
	echo json_encode($cities);
}
else
{
	$query = "SELECT DISTINCT country FROM country_state_city";
	$statement = $connect->query($query);
	$countries = $statement->fetchAll(PDO::FETCH_ASSOC);
	echo json_encode($countries);
}


?>


This PHP code serves as the backend script for handling requests related to dynamic dependent dropdowns. Let's break it down line by line:


header("Access-Control-Allow-Origin:* ");
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: *");


These lines set the HTTP headers to enable Cross-Origin Resource Sharing (CORS). CORS headers are essential when your frontend and backend are hosted on different domains to allow requests from the frontend to the backend.


$connect = new PDO("mysql:host=127.0.0.1;dbname=testing", "root", "password");


This line establishes a connection to a MySQL database using the PDO (PHP Data Objects) extension. Adjust the connection parameters (host, dbname, root, password) according to your database configuration.


if(isset($_GET['country']))
{
	$query = "SELECT DISTINCT state FROM country_state_city WHERE country = ?";
	$statement = $connect->prepare($query);
	$statement->execute([$_GET['country']]);
	$states = $statement->fetchAll(PDO::FETCH_ASSOC);
	echo json_encode($states);
}


This block checks if the request includes a 'country' parameter. If true, it prepares and executes a SQL query to fetch distinct states based on the provided country. The fetched data is then encoded in JSON format and echoed back to the client.


else if(isset($_GET['state']))
{
	$query = "SELECT DISTINCT city FROM country_state_city WHERE state = ?";
	$statement = $connect->prepare($query);
	$statement->execute([$_GET['state']]);
	$cities = $statement->fetchAll(PDO::FETCH_ASSOC);
	echo json_encode($cities);
}


This block checks if the request includes a 'state' parameter. If true, it prepares and executes a SQL query to fetch distinct cities based on the provided state. The fetched data is then encoded in JSON format and echoed back to the client.


else
{
	$query = "SELECT DISTINCT country FROM country_state_city";
	$statement = $connect->query($query);
	$countries = $statement->fetchAll(PDO::FETCH_ASSOC);
	echo json_encode($countries);
}


If neither 'country' nor 'state' parameters are present in the request, this block executes a SQL query to fetch distinct countries. The fetched data is encoded in JSON format and echoed back to the client.

Run React JS Application


After follow all above step now we need to check output in the browser. So we have goes to terminal and goes into our working directory and run following command.


npm run dev





Once you have run this command then it will start server and provide base url of our React App. So you have to open that url in browser and you can able to view React.js Cascading Dropdown box on web page.

Conclusion


Congratulations! You've successfully created a dynamic cascading dropdown box in React JS with PHP. Feel free to adapt and expand upon this tutorial based on your specific needs.





Sunday, 17 December 2023

A Beginner's Guide to Implementing File Uploads in React.js with PHP Backend


If you're diving into the world of web development with React.js and need to incorporate file uploads into your project, you're in the right place. This guide will walk you through the process step by step, utilizing a PHP backend API. By the end, you'll have a solid understanding of how to implement file uploads seamlessly in your React.js application.

Prerequisites


Before we get started, make sure you have the following installed:

  • Node.js and npm (Node Package Manager)
  • React.js development environment set up
  • A PHP server for the backend (e.g., XAMPP, WampServer, or any other PHP server of your choice)

A Beginner's Guide to Implementing File Uploads in React.js with PHP Backend






Step 1: Set Up Your React.js App


First we have to create React App in our local computer. So if you want to know how to install React App then you you have to follow this React.js Crud Application Tutorial. In which you can find step by step guid for download and install dependencies in our React Application.

Step 2: Install Dependencies


Install the necessary packages for file handling in React:


npm install bootstrap


Step 3: Create a File Upload Component


In your src folder, there is one App.jsx in which we have create File Upload component. This component will handle the file upload functionality.

src/App.jsx

import React, { useState, useRef } from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';

function App() {
	
	const [selectedFile, setSelectedFile] = useState(null);

	const [imageLink, setImageLink] = useState(null);

	const [validationError, setValidationError] = useState(null);

	const fileInputRef = useRef(null);

	const handleFileChange = (event) => {

		const file = event.target.files[0];
		if(file)
		{
			const allowedExtension = ['.jpg', '.png'];
			const selectedFileExtension = file.name.split('.').pop().toLowerCase();
			if(allowedExtension.includes('.' + selectedFileExtension))
			{
				setSelectedFile(file);
				setValidationError(null);
			}
			else
			{
				setSelectedFile(null);
				setValidationError('Invalid file extension. Please select a file with .jpg or .png extension.');
				fileInputRef.current.value = '';
			}
		}

	};

	const handleUpload = async() => {
		if(selectedFile)
		{
			const formData = new FormData();
			formData.append('file', selectedFile);
			const response = await fetch('http://localhost/tutorial/file-upload/api/upload.php', {
				method : 'POST',
				body : formData
			});

			const responseData = await response.json();
			setImageLink(responseData.image_link);
			fileInputRef.current.value = '';
		}
		else
		{
			setValidationError('Please select a file before uploading.');
		}
	};

	return (
		<div className="container">
            <h1 className="mt-5 mb-5 text-center"><b>Upload File in React.js</b></h1>

            <div className="card">
                <div className="card-header">Upload File in React.js</div>
                <div className="card-body">
                    <div className="row">
                        <div className="col col-2"><b>Select File</b></div>
                        <div className="col col-3">
                        	<input type="file" ref={fileInputRef} onChange={handleFileChange} />
                        </div>
                        <div className="col col-3">
                        	<button className="btn btn-primary" onClick={handleUpload}>Upload</button>
                        </div>
                    </div>
                    <div className="row">
                        <div className="col col-2">&nbsp;</div>
                        <div className="col col-3">
                            {validationError && (
                            	<p className="text-danger">{validationError}</p>
                            )}

                            {imageLink && (
                            	<div>
                                    <p><b>Uploaded Image : </b></p>
                                    <img src={imageLink} className="img-fluid img-thumbnail" />
                                </div>
                            )}
                        </div>
                    </div>
                </div>
            </div>
        </div>
	)
}

export default App


Import Statements:



import React, { useState, useRef } from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';


  • The code imports React, which is necessary for creating React components.
  • It also imports the useState and useRef hooks from React. useState is used to manage component state, and useRef is used to create a reference to the file input element.
  • The bootstrap.min.css file is imported to apply Bootstrap styling to the component.

Functional Component Declaration:



function App() {
  // ... component logic
}


  • This code defines a functional component named App.

State Hooks:



const [selectedFile, setSelectedFile] = useState(null);
const [imageLink, setImageLink] = useState(null);
const [validationError, setValidationError] = useState(null);


  • Three state variables (selectedFile, imageLink, and validationError) are initialized using the useState hook.
  • selectedFile represents the currently selected file for upload.
  • imageLink holds the link to the uploaded image, if any.
  • validationError stores any validation error messages.

useRef Hook:



const fileInputRef = useRef(null);


  • The useRef hook is used to create a reference (fileInputRef) to the file input element. This reference will be used to manipulate the file input, such as clearing its value.

Event Handler - handleFileChange:



const handleFileChange = (event) => {
  // ... file change logic
};


handleFileChange: This function is triggered when a user selects a file using the file input. It performs validation to check the file extension and updates the state accordingly.


const file = event.target.files[0];


  • This line extracts the first file from the array of files selected by the user through the file input.

if (file) {
  // ...
}


  • This condition checks whether a file is actually selected. If not, the subsequent logic is not executed.

const allowedExtension = ['.jpg', '.png'];


  • An array (allowedExtension) is created, containing the allowed file extensions (in this case, '.jpg' and '.png').

const selectedFileExtension = file.name.split('.').pop().toLowerCase();


  • The selected file's name is split at the period ('.') to extract the file extension. It is then converted to lowercase for case-insensitive comparison.

if (allowedExtension.includes('.' + selectedFileExtension)) {
  // If allowed, set the selected file in the component state
  setSelectedFile(file);
  // Clear any previous validation error
  setValidationError(null);
} else {
  // If not allowed, set the selected file to null
  setSelectedFile(null);
  // Set a validation error message
  setValidationError('Invalid file extension. Please select a file with .jpg or .png extension.');
  // Clear the file input value to prevent submitting an invalid file
  fileInputRef.current.value = '';
}


  • This block of code checks if the selected file's extension is included in the allowedExtension array.
  • If the extension is allowed, it sets the selected file in the component state (setSelectedFile(file)) and clears any previous validation error.
  • If the extension is not allowed, it sets the selected file to null, sets a validation error message, and clears the file input value to prevent submitting an invalid file.

This handleFileChange function is designed to handle the logic when a user selects a file in the file input. It ensures that the selected file has a valid extension before updating the component state or displaying a validation error.





Event Handler - handleUpload:



const handleUpload = async () => {
  // ... file upload logic
};


  • handleUpload: This function is called when the user clicks the "Upload" button. It checks if a file is selected, and if so, it constructs a FormData object and sends a POST request to the PHP backend.

if (selectedFile) {
  // ...
} else {
  // ...
}


  • This condition checks whether a file is selected (selectedFile). If no file is selected, it executes the else block to set a validation error.

const formData = new FormData();


  • This line creates a new FormData object. FormData is used to construct a set of key/value pairs representing form fields and their values.

formData.append('file', selectedFile);


  • The selected file is appended to the FormData object with the key 'file'.

const response = await fetch('http://localhost/tutorial/file-upload/api/upload.php', {
  method: 'POST',
  body: formData
});


  • The fetch function is used to send a POST request to the specified URL (http://localhost/tutorial/file-upload/api/upload.php).
  • The request includes the method ('POST') and the body, which is set to the FormData object containing the selected file.

const responseData = await response.json();


  • The response from the server is expected to be in JSON format. This line parses the JSON data using await response.json().

setImageLink(responseData.image_link);


  • If the upload is successful, the image link returned from the server is set in the component state using setImageLink.

fileInputRef.current.value = '';


  • After a successful upload, the file input value is cleared to allow selecting a new file in the future.

setValidationError('Please select a file before uploading.');


  • If no file is selected, a validation error message is set to inform the user to select a file before attempting to upload.

This handleUpload function is responsible for sending a file to the PHP backend for upload, handling the server's response, and updating the component state accordingly. It also takes care of error handling and validation messages.

JSX Markup:



return (
		<div className="container">
            <h1 className="mt-5 mb-5 text-center"><b>Upload File in React.js</b></h1>

            <div className="card">
                <div className="card-header">Upload File in React.js</div>
                <div className="card-body">
                    <div className="row">
                        <div className="col col-2"><b>Select File</b></div>
                        <div className="col col-3">
                        	<input type="file" ref={fileInputRef} onChange={handleFileChange} />
                        </div>
                        <div className="col col-3">
                        	<button className="btn btn-primary" onClick={handleUpload}>Upload</button>
                        </div>
                    </div>
                    <div className="row">
                        <div className="col col-2">&nbsp;</div>
                        <div className="col col-3">
                            {validationError && (
                            	<p className="text-danger">{validationError}</p>
                            )}

                            {imageLink && (
                            	<div>
                                    <p><b>Uploaded Image : </b></p>
                                    <img src={imageLink} className="img-fluid img-thumbnail" />
                                </div>
                            )}
                        </div>
                    </div>
                </div>
            </div>
        </div>
	)


  • The return statement contains the JSX markup for the component.
  • The component is structured using Bootstrap classes for styling.
  • It includes a file input, an "Upload" button, and displays validation errors or the uploaded image based on the state.

Export Component



export default App;


  • The App component is exported to be used in other parts of the application.

Overall, this component provides a simple file upload form using React.js, where users can select an image file, validate its extension, and upload it to a PHP backend. The UI is styled using Bootstrap classes for a clean and responsive design.





Step 4: Set Up the PHP Backend


Create a PHP file (upload.php) in your React Application working api directory to handle file uploads. Here's a basic example:

api/upload.php

<?php

//upload.php

header("Access-Control-Allow-Origin:* ");
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: *");

$upload_directory = '../upload/';
$file_name_array = explode(".", $_FILES['file']['name']);
$file_name = time() . '.' . end($file_name_array);
$upload_file = $upload_directory . $file_name;
$image_link = 'http://localhost/tutorial/file-upload/upload/' . $file_name;
if(!file_exists($upload_directory))
{
	mkdir($upload_directory, 0777, true);
}

if(move_uploaded_file($_FILES['file']['tmp_name'], $upload_file))
{
	echo json_encode([
		'message' => 'File uploaded successfully', 
		'image_link' => $image_link
	]);
}

?>

CORS Headers:



header("Access-Control-Allow-Origin:* ");
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: *");


  • These lines set CORS headers to allow cross-origin requests. This is important when the frontend (React.js) and backend (PHP) are hosted on different domains.

Upload Directory and File Naming:



$upload_directory = '../upload/';
$file_name_array = explode(".", $_FILES['file']['name']);
$file_name = time() . '.' . end($file_name_array);


  • $upload_directory is set to the relative path where the uploaded files will be stored.
  • The uploaded file's name is modified to include the current timestamp, ensuring a unique filename.

Complete File Path and Image Link:



$upload_file = $upload_directory . $file_name;
$image_link = 'http://localhost/tutorial/file-upload/upload/' . $file_name;


  • The complete file path is formed using $upload_directory and $file_name.
  • An $image_link is created, representing the URL where the uploaded image can be accessed.

Create Upload Directory if Not Exists:



if (!file_exists($upload_directory)) {
    mkdir($upload_directory, 0777, true);
}


  • This block of code checks if the upload directory exists. If not, it creates the directory with full permissions.

Move Uploaded File:



if (move_uploaded_file($_FILES['file']['tmp_name'], $upload_file)) {
    // If successful, return a JSON response with a success message and the image link
    echo json_encode([
        'message' => 'File uploaded successfully',
        'image_link' => $image_link
    ]);
}


  • The move_uploaded_file function is used to move the uploaded file from its temporary location to the specified directory.
  • If the file is moved successfully, a JSON response is echoed with a success message and the image link.

This PHP script is designed to handle file uploads, create a unique filename, move the file to a specified directory, and return a JSON response with a success message and the URL of the uploaded image. It also includes CORS headers to allow cross-origin requests from the frontend.

Step 5: Run Your Applications


Start your React.js development server:


npm run dev


Start your PHP server and visit your React app in the browser. You should now be able to upload files successfully!

Congratulations! You've successfully implemented a file upload functionality in React.js using a PHP backend. Feel free to customize and expand upon this foundation to meet your specific project requirements. This guide should serve as a solid starting point for anyone looking to integrate file uploads into their React.js applications. Happy coding!