Skip to content

ashfaqch/react-app-with-minimum-configuration

Repository files navigation

react-app-with-minimum-configuration

In this example I have demonstrated that how to Create a react app with minimum configuration required.

Steps:

Create a new folder for the react app:

Run following commands.

  • mkdir react-app
  • cd react-app
  • npm init (npm init will ask you a bunch of questions. Just press enter for the defaults.)

Install dependencies:

Run following commands.

  • npm install --save react
  • npm install --save react-dom
  • npm install --save typescript
  • npm install --save-dev @babel/preset-react
  • npm install --save-dev @babel/preset-env
  • npm install --save-dev parcel-bundler

Create .babelrc file:

Create the .babelrc file. This file tells parcel that we are using ES6 and React.

{
    "presets": [
        "@babel/preset-react"
    ]
}

Create tsconfig.json file:

Create the tsconfig.json file. To define compiler options.

{
    "compilerOptions": {
        "jsx": "react"
    }
}

Create index.tsx file:

Create startup react component.

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

ReactDOM.render(
	<>
		<h1>React App</h1>
		<p>With minimum configuration using Parcel and Typescript.</p>
	</>,
	document.getElementById('root')
);

Create index.html file:

Copy following code to index.html file.

<!DOCTYPE html>
<html>

<head>
    <title>React App</title>
</head>

<body>
    <div id="root"></div>
    <script src="./index.tsx"></script>
</body>

</html>

Create index.css file:

Copy following code to index.css file.

body {
    background-color: #282c34;
    color: #ffffff;
    text-align: center;
}

Add a script entry to package.json scripts:

"start": "parcel index.html"

Build & Run

  1. Run npm install to install packages
  2. Run npm start and navigate to http://localhost:1234/ to view app.

About

React app with minimum configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published