Giter Site home page Giter Site logo

maryanadey / goit-react-hw-01-components Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 627 KB

https://maryanadey.github.io/goit-react-hw-01-components/

Home Page: https://maryanadey.github.io/goit-react-hw-01-components/

License: MIT License

HTML 4.54% CSS 34.51% JavaScript 60.36% Shell 0.60%

goit-react-hw-01-components's Introduction

Создание и настройка React-App

  1. Создать репозиторий и склонировать на ПК
  2. Установить React application Открыть терминал в папке проекта и установить react-app

npx create-react-app . 3. Удалить ненужные файлы 3.1 public/index.html В папке public оставить только index.html. Удалить код из index.html, создать базовую разметку с помощью Emmet.

Разметка может выглядеть так:

<title>Document</title>
3.2 /src В папке /src достаточно оставить index.js, App.js, index.css, App.css

В папке /src создать папку components для размещения будущих компонентов.

3.3 index.js В index.js достаточно оставить следующий код:

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

ReactDOM.render( <React.StrictMode> </React.StrictMode>, document.getElementById('root'), ); 3.4 App.js В App.js достаточно оставить следующий код:

// App.js import './App.css';

function App() { return

TEST
; }

export default App; 3.4 App.css В App.css удалить ненужные стили.

  1. Запустить сервер проверить, нет ли ошибкок. npm start
  2. Настройка pre-commit хуков 5.1 Установка зависимостей Установить в проект следующие пакеты.

Примечание: react-app корректно работает с более старой версией eslint 7.11.0

npm install --save-dev prettier [email protected] 5.2 Инициализация lint-staged и husky Пользователям MacOS и Linux систем необходимо выполнить в терминале следующую команду. Она установит и настроит husky и lint-staged в зависимости от инструментов качества кода из зависимостей проекта в package.json.

npx mrm lint-staged Пользователям Windows необходимо выполнить следующую команду. Она делает тоже самое.

npx mrm@2 lint-staged 5.3 Настройка в VSCode Провреить наличие следующих раширений:

Prettier - Code formatter

Formatting Toggle

ESLint

Можно добавить настройки Prettier, создав файл .prettierrc.yaml в корневой папке проекта. Можно добавить следующие настройки.

printWidth: 100 useTabs: false semi: true singleQuote: true trailingComma: 'all' bracketSpacing: true arrowParens: 'avoid' proseWrap: 'always' Открыть настройки VSCode и проверить следующее:

autoSave

Превью настроек VSCode

formatOnSave

Превью настроек VSCode

codeActionsOnSave

Превью настроек VSCode

Или же добавить код в файл settings.json

Ctrl + Shift + P => settings.json => Open Settings (JSON)

{ "files.autoSave": "onFocusChange", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true } } 6. Настройка Деплоя Ссылка на create-react-app

В package.json добавить следующию строку:

"homepage": "https://имя_пользователя.github.io/имя_репозитория" Сделать билд через терминал:

npm run build Установить пакет gh-pages

npm install --save gh-pages В package.json в scripts добавить 2 скрипта:

"scripts": { // добавить к остальным скриптам "predeploy": "npm run build", "deploy": "gh-pages -d build", Запустить деплой

npm run deploy Скрипт predeploy запускать не нужно, он выполнится автоматически. Будет создана ветка gh-pages, выполнен автоккоммит и её пуш в ваш репозиторий на GitHub.сom, в настройках GitHub Pages автоматически будет подставлена ветка gh-pages, достаточно взять ссылку. Сам проект как обычно коммитим, пушим, чтобы код отразился в ветке main.

Если у кого-то не получилось настроить, я не виноват :) Не забудьте 7. Дальнейшая работа с проектом Работаем, делаем коммиты и пушим на GitHub как обычно. Страница автоматически не обновится. Если нужно залить на GitHub Pages, делаете повторно npm run deploy. Или же можете настроить автодеплой. Меня этот вопрос на данный момент не волнует.

goit-react-hw-01-components's People

Contributors

maryanadey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.