Создание проекта
Глобальная установка
sudo npm install -g create-react-app
Создание проекта
create-react-app maximapp
Заходим в папку с проектом и удаляем всё содержимое папок public и src
Создаём файл index.html в папке public
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Приложение</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
Создаём файл index.js в папке src
import React from 'react';
import {render} from 'react-dom';
function PrintMyString() {
return (
<div>
<h1>I am Maxim</h1>
<h2>It is my application</h2>
<h3>Hello world !!!</h3>
</div>
)
}
render(<PrintMyString/>, document.getElementById('root'));
Запускаем проект
Пишем в консоли
npm start
В адресной строке пишем
http://localhost:3000/
После этого откроется созданный проект.
Last updated
Was this helpful?