Arquitetura de pastas para projetos #React

Minha base sรฃo as arquiteturas: #ITCSS e #RSCSS.

Visรฃo geral do projeto e na thread mostro como organizo a pasta ๐Ÿ“‚๐™จ๐™ง๐™˜

๐Ÿ“‚.๐š๐š’๐š๐š‘๐šž๐š‹
๐Ÿ“‚.๐šŸ๐šœ๐šŒ๐š˜๐š๐šŽ
๐Ÿ“‚๐šŠ๐š™๐š’
๐Ÿ“‚๐š™๐šž๐š‹๐š•๐š’๐šŒ
๐Ÿ“‚๐™จ๐™ง๐™˜๐Ÿ“Œ
โˆŸ๐Ÿ“‚๐Ÿงต

๐Ÿ“ŒOnde estรก
๐ŸงตPrรณximo passo
๐Ÿ“‚๐™จ๐™ง๐™˜๐Ÿ“Œ
โˆŸ๐Ÿ“‚๐šŠ๐šœ๐šœ๐šŽ๐š๐šœ๐Ÿงต
โˆŸ๐Ÿ“‚๐™ถ๐š•๐š˜๐š‹๐šŠ๐š•๐š‚๐š๐šข๐š•๐šŽ๐šœ
โˆŸ๐Ÿ“‚๐šŒ๐š˜๐š–๐š™๐š˜๐š—๐šŽ๐š—๐š๐šœ
โˆŸ๐Ÿ“‚๐š•๐šŠ๐šข๐š˜๐šž๐š๐šœ
โˆŸ๐Ÿ“‚๐š™๐šŠ๐š๐šŽ๐šœ
โˆŸ๐Ÿ“‚๐šœ๐šŽ๐š›๐šŸ๐š’๐šŒ๐šŽ๐šœ
โˆŸ๐Ÿ“„๐š–๐šŠ๐š’๐š—.๐š“๐šœ๐šก
โˆŸ๐Ÿ“„๐š›๐š˜๐šž๐š๐šŽ๐š›.๐š“๐šœ๐šก
๐Ÿ“‚๐™จ๐™ง๐™˜
โˆŸ๐Ÿ“‚๐šŠ๐šœ๐šœ๐šŽ๐š๐šœ๐Ÿ“Œ
โˆŸ๐Ÿ“‚๐š๐š˜๐š—๐š๐šœ
โˆŸ๐Ÿ“‚๐š’๐š–๐šŠ๐š๐šŽ๐šœ
โˆŸ๐Ÿ“‚๐š’๐šŒ๐š˜๐š—๐šœ
โˆŸ๐Ÿ“‚๐™ถ๐š•๐š˜๐š‹๐šŠ๐š•๐š‚๐š๐šข๐š•๐šŽ๐šœ๐Ÿงต
โˆŸ๐Ÿ“‚๐šŒ๐š˜๐š–๐š™๐š˜๐š—๐šŽ๐š—๐š๐šœ
โˆŸ๐Ÿ“‚๐š•๐šŠ๐šข๐š˜๐šž๐š๐šœ
โˆŸ๐Ÿ“‚๐š™๐šŠ๐š๐šŽ๐šœ
โˆŸ๐Ÿ“‚๐šœ๐šŽ๐š›๐šŸ๐š’๐šŒ๐šŽ๐šœ
โˆŸ๐Ÿ“„๐š–๐šŠ๐š’๐š—.๐š“๐šœ๐šก
โˆŸ๐Ÿ“„๐š›๐š˜๐šž๐š๐šŽ๐š›.๐š“๐šœ๐šก
๐Ÿ“‚๐™จ๐™ง๐™˜
โˆŸ๐Ÿ“‚๐™ถ๐š•๐š˜๐š‹๐šŠ๐š•๐š‚๐š๐šข๐š•๐šŽ๐šœ๐Ÿ“Œ
โˆŸ๐Ÿ“‚๐š‚๐šŽ๐š๐š๐š’๐š—๐š๐šœ
โˆŸ๐Ÿ“‚๐™ถ๐šŽ๐š—๐šŽ๐š›๐š’๐šŒ
โˆŸ๐Ÿ“‚๐™ด๐š•๐šŽ๐š–๐šŽ๐š—๐š๐šœ
โˆŸ๐Ÿ“‚๐š๐š˜๐š˜๐š•๐šœ
โˆŸ๐Ÿ“„๐š’๐š—๐š๐šŽ๐šก.๐š“๐šœ๐šก
โˆŸ๐Ÿ“‚๐šŒ๐š˜๐š–๐š™๐š˜๐š—๐šŽ๐š—๐š๐šœ๐Ÿงต

Pra saber mais sobre a pasta GlobalStyles procure por ITCSS
๐Ÿ“‚๐™จ๐™ง๐™˜
โˆŸ๐Ÿ“‚๐šŒ๐š˜๐š–๐š™๐š˜๐š—๐šŽ๐š—๐š๐šœ
โˆŸ๐Ÿ“‚๐™ฑ๐šž๐š๐š๐š˜๐š—๐Ÿ“Œ
โˆŸ๐Ÿ“„๐š’๐š—๐š๐šŽ๐šก.๐š“๐šœ๐Ÿงต
โˆŸ๐Ÿ“„๐™ฑ๐šž๐š๐š๐š˜๐š—.๐šœ๐š๐š˜๐š›๐š’๐šŽ๐šœ.๐š“๐šœ
โˆŸ๐Ÿ“‚๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—
โˆŸ๐Ÿ“‚๐™ฑ๐šž๐š๐š๐š˜๐š—
โˆŸ๐Ÿ“„๐š’๐š—๐š๐šŽ๐šก.๐š“๐šœ๐Ÿ“Œ
โˆŸ๐Ÿ“„๐™ฑ๐šž๐š๐š๐š˜๐š—.๐šœ๐š๐š˜๐š›๐š’๐šŽ๐šœ.๐š“๐šœ๐Ÿงต

Quando um componente รฉ simples e sรณ precisamos de um #CSS para representar ele, uso a ๐™ž๐™ฃ๐™™๐™š๐™ญ.๐™Ÿ๐™จ com #styledComponents. Um cรณdigo de exemplo: import styled, { css } from 'styled-components'  const hasPi
โˆŸ๐Ÿ“‚๐™ฑ๐šž๐š๐š๐š˜๐š—
โˆŸ๐Ÿ“„๐š’๐š—๐š๐šŽ๐šก.๐š“๐šœ
โˆŸ๐Ÿ“„๐™ฑ๐šž๐š๐š๐š˜๐š—.๐šœ๐š๐š˜๐š›๐š’๐šŽ๐šœ.๐š“๐šœ๐Ÿ“Œ
โˆŸ๐Ÿ“‚๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—๐Ÿงต

O ๐˜ฝ๐™ช๐™ฉ๐™ฉ๐™ค๐™ฃ.๐™จ๐™ฉ๐™ค๐™ง๐™ž๐™š๐™จ.๐™Ÿ๐™จ รฉ um arquivo de documentaรงรฃo do componente. Uso o @storybookjs, o que vocรช usa? import React from 'react'  import Button from './index'  exp
โˆŸ๐Ÿ“‚๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š— ๐Ÿงต
โˆŸ๐Ÿ“„๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐šœ๐š๐š˜๐š›๐š’๐šŽ๐šœ.๐š“๐šœ๐šก
โˆŸ๐Ÿ“„๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐š“๐šœ๐šก
โˆŸ๐Ÿ“„๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐šœ๐š๐šข๐š•๐šŽ๐šœ.๐š“๐šœ
โˆŸ๐Ÿ“„๐šž๐šœ๐šŽ๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐š“๐šœ
โˆŸ๐Ÿ“„๐š’๐š—๐š๐šŽ๐šก.๐š“๐šœ๐šก
โˆŸ๐Ÿ“‚๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—๐Ÿ“Œ
โˆŸ๐Ÿ“„๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐š“๐šœ๐šก๐Ÿงต

๐™‡๐™ค๐™œ๐™ค๐™ช๐™ฉ๐˜ฝ๐™ช๐™ฉ๐™ฉ๐™ค๐™ฃ รฉ um componente mais complexo que tem a responsabilidade de realizar o logout quando o usuรกrio clicar nele, sendo assim nรฃo conseguimos resolver ele apenas com CSS
โˆŸ๐Ÿ“‚๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—
โˆŸ๐Ÿ“„๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐š“๐šœ๐šก๐Ÿ“Œ
โˆŸ๐Ÿ“„๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐šœ๐š๐šข๐š•๐šŽ๐šœ.๐š“๐šœ๐Ÿงต

๐™‡๐™ค๐™œ๐™ค๐™ช๐™ฉ๐˜ฝ๐™ช๐™ฉ๐™ฉ๐™ค๐™ฃ.๐™Ÿ๐™จ๐™ญ รฉ a camada do componente responsรกvel pela estrutura (#html), ele pode receber props mas isso nem sempre รฉ necessรกrio import { func } from 'prop-types' import S from '../LogoutBu
โˆŸ๐Ÿ“‚๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—
โˆŸ๐Ÿ“„๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐šœ๐š๐šข๐š•๐šŽ๐šœ.๐š“๐šœ๐Ÿ“Œ
โˆŸ๐Ÿ“„๐šž๐šœ๐šŽ๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐š“๐šœ๐Ÿงต

๐˜ฝ๐™ช๐™ฉ๐™ฉ๐™ค๐™ฃ.๐™จ๐™ฉ๐™ฎ๐™ก๐™š๐™จ.๐™Ÿ๐™จ รฉ responsรกvel por cuidar da camada visual (#CSS), a seguir um cรณdigo de exemplo: import styled from 'styled-components' import Button from '.
โˆŸ๐Ÿ“‚๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—
โˆŸ๐Ÿ“„๐šž๐šœ๐šŽ๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐š“๐šœ๐Ÿ“Œ
โˆŸ๐Ÿ“„๐š’๐š—๐š๐šŽ๐šก.๐š“๐šœ๐šก๐Ÿงต

๐™ช๐™จ๐™š๐™‡๐™ค๐™œ๐™ค๐™ช๐™ฉ๐˜ฝ๐™ช๐™ฉ๐™ฉ๐™ค๐™ฃ.๐™Ÿ๐™จ๐™ญ รฉ responsรกvel pela regra de negรณcio, ou seja o cรณdigo responsรกvel para realizar o logout quando o usuรกrio clicar no botรฃo: import { useNavigate } from 'react-router-dom' import authSe
โˆŸ๐Ÿ“‚๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—
โˆŸ๐Ÿ“„๐šž๐šœ๐šŽ๐™ป๐š˜๐š๐š˜๐šž๐š๐™ฑ๐šž๐š๐š๐š˜๐š—.๐š“๐šœ
โˆŸ๐Ÿ“„๐š’๐š—๐š๐šŽ๐šก.๐š“๐šœ๐šก๐Ÿ“Œ
โˆŸ๐Ÿ“‚๐š•๐šŠ๐šข๐š˜๐šž๐š๐šœ๐Ÿงต

๐™ž๐™ฃ๐™™๐™š๐™ญ.๐™Ÿ๐™จ๐™ญ รฉ responsรกvel por juntar a regra de negรณcio (๐™ช๐™จ๐™š๐™‡๐™ค๐™œ๐™ค๐™ช๐™ฉ๐˜ฝ๐™ช๐™ฉ๐™ฉ๐™ค๐™ฃ.๐™Ÿ๐™จ) com a estrutura (๐™‡๐™ค๐™œ๐™ค๐™ช๐™ฉ๐˜ฝ๐™ช๐™ฉ๐™ฉ๐™ค๐™ฃ.๐™Ÿ๐™จ๐™ญ): import LogoutButton from './LogoutButton' import useLogoutBu
๐Ÿ“‚๐™จ๐™ง๐™˜
โˆŸ๐Ÿ“‚๐š•๐šŠ๐šข๐š˜๐šž๐š๐šœ๐Ÿ“Œ๐Ÿงต

๐™ก๐™–๐™ฎ๐™ค๐™ช๐™ฉ๐™จ sรฃo componentes com objetivo รบnico, vocรช pode reutiliza-los mas eles tรชm caracteristicas muito especificas. Por exemplo:

- HeaderSite

Nรฃo conseguimos reutilizar o HeaderSite da mesma forma que podemos reutilizar um Button
๐Ÿงต
Dentro da pasta ๐™ก๐™–๐™ฎ๐™ค๐™ช๐™ฉ๐™จ temos a mesma estrutura que adotamos para o componente LogoutButton

Nรฃo vou entrar nos detalhes das outras pastas e arquivos porque รฉ uma abordagem comum em projetos #FrontEnd com diferentes frameworks

๐Ÿงต
Ah! Se sentiu falta da camada de testes, foi de propรณsito porque esse tema vai alรฉm da arquitetura de pastas e merece uma thread รบnica para ser apresentada e discutida.

๐Ÿงต
O objetivo dessa thread รฉ mostrar como faรงo a arquitetura de pastas de um projeto React, nรฃo expliquei detalhes de como o framework funciona.

Se tiver qualquer dรบvida, critica e sugestรตes nรฃo deixe de mandar, isso nรฃo รฉ uma bala de prata e nรฃo quero ser o dono da verdade.

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with MarcoBrunoD3v ๐Ÿ‡ง๐Ÿ‡ท ๐Ÿ‡ธ๐Ÿ‡ช

MarcoBrunoD3v ๐Ÿ‡ง๐Ÿ‡ท ๐Ÿ‡ธ๐Ÿ‡ช Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @marcobrunodev

Apr 7
Para que servem os mรฉtodos HTTP tambรฉm conhecidos como verbos HTTP? Visรฃo para pessoas de #FrontEnd que querem consumir uma API

Thread feliz ๐Ÿงต
โžก๏ธIntroduรงรฃo

Imagine que vocรช precisa criar uma aplicaรงรฃo com 4 funcionalidades, de criar, ler, atualizar e deletar os dados de um usuรกrio

Exemplo de estrutura do nosso usuรกrio:
Felizmente vocรช tem uma API e poderรก enviar os dados do usuรกrio para a rota (recurso) a seguir: /user

Outra coisa feliz รฉ que vocรช tem 5 mรฉtodos HTTPs que estรฃo disponรญveis nessa rota /user, sendo eles:

โžก๏ธGet
โžก๏ธPost
โžก๏ธPut
โžก๏ธPatch
โžก๏ธDelete

Pra que servem esses mรฉtodos?

โฌ‡๏ธ
Read 14 tweets
Mar 11
O que vocรช precisa saber de #JavaScript para aprender #ReactJS de forma feliz

Thread ๐Ÿงต
โžก๏ธ Base do #JavaScript

โ†ฉ๏ธO que รฉ JavaScript?
โ†ฉ๏ธAtribuiรงรฃo de valores
โ†ฉ๏ธDiferenรงa entre: var, let e const
โ†ฉ๏ธOperadores: +, -, /, *, % e **
โ†ฉ๏ธIncremento: ++x e x++
โ†ฉ๏ธDecremento: --x e x--
โ†ฉ๏ธComparadores: ===, !==, <, >, >= e <=
โ†ฉ๏ธCondicionais: if, else e switch-case
โ†ฉ๏ธConsole.log
โ†ฉ๏ธimport/export

โ†ฉ๏ธLoops
โฌ‡๏ธ
โ†ช๏ธWhile
โ†ช๏ธFor
โ†ช๏ธFor...in
โ†ช๏ธFor...of
โ†ช๏ธControles de fluxo: break, continue, return
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(