Letícia Rodrigues
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Playlist Reactjs - Resumo >[color=#055b5c]**Autor:** Letícia Rodrigues da Silva **Número:** 25 **Turma:** IndoD [toc] ## 1 - configuração Visual code; - abrir projeto no visual code; - podemos mudar a porta que o react vai rodar; - o react tem apenas um arquivo html que faz um vinculo com o arquivo index.js; - react é baseado em componentes, e app o componente inicial; - import e export são comandos atuais do JS; - todo componente precisa retornar uma tag principal ou seja uma tag mãe; - html = class; JS = ClassName; - tag style não funciona muito bem no react, como no html; - todas as tegs tem que fechar no react; - em js as imagens tem que ser passadas como tag ou usadas pelo public; - em js o sistema de pastas também funcionam; - podemos usar recusos externos tambem, como fotos da web; ## 2 **Componentes:** Componentes são funções que retornam um bloco de html/jsx. **Estado:** momento atual das informações que o componente pode armazenar, já que ele pode guardar informações e podem ser alteradas consequentemente mudando o estado e chamando a função novamente. - Podemos ter mais de uma variavel de estado - São criadas como const(constante) - useState = Função - Vinculo de uma função com uma tag é dado atravez das funções que inciam com "ON" **Relacionamento de componentes:** - *Criar componente:* ex: ```javascript= function Counter() { return( <div> </div> ) } ``` - *Exportar componente* ```javascript= export default Counter; ``` - *Importar componente* ```javascript= import Counter from './Counter' ``` - *Usar componente* Usar como uma tag ```javascript= < Counter /> ``` - *Usar atributo* enviar ```javascript= < Counter value={conter}/> ``` receber ```javascript= <div> {props.value} </div> ``` - *Conversa de pai e filho* função de alta ordem ## 3 - pastas, abrir arquivo - nome do componenete sempre tem que iniciar com a letra maiuscula - configurar navegação do projeto (routes) - dependencia {react-router-dom} - exact{true} = fazer uma comparação exata de rota - route notFound ```javascript= <Route path="*" component={NotFound} ``` **path="*" = path generico** - imagem **Importar** ```javascript= import ... from 'rota pasta public' ``` **Usar** ```javascript= <img src={nome img} alt="" /> ``` - importar link e usar como tag a para ajudar na navegação ```javascript= import { Link } from 'react-router-dom' ``` ```javascript= <Link to="/nome pagina"> ... </Link> ``` ## 4 Temos varias formas de estilizar componentes, entre elas usando o CSS ou o npm styled components. - **Css** Usamos o import para importar o arquivo CSS e programamos o arquivo em css normalmente. ```javascript= import './nome arquivo css' ``` Temos que criar o arquivo dentro da mesma pasta onde a estilização será feita. Para criar uma classe utilizamos 'class name' e não apenas 'class' como no HTML. **Imagens** - background-image: url('rota pastas') Em algumas versões a imagem deve ser pega do public, e usando a barra para referenciar as pastas **pode ocorrer conflitos de nome** - **Styled** **Import** ```javascript= import styled from 'styled-components' const nomeVariavel = styled.tagrepresentada` formatação `; ``` usamos como componente/tag **import deve ser sempre declarado no inicio do arquivo** & = simbolizar a div/tag **podemos criar classes também** ## 5 **Renderização:** Exibir informações para o usuario - **Renderização estatica:** não muda, ele sempre vai renderizar a mesma coisa. - **Renderização variavel:** pode ser alterada, se existir uma função. - **Renderização por componente:** criar um componente e importar, porém ele vai continuar estartico, se não for configurado para variavel. - **Renderização condicional:** se o componente vai ser exibido ou não atravez de operadores. - **Renderização repetição:** coleção de objetos que podem ser convertidos pra componentes. map = função que mapeia componentes **props** ## 6 **Estado=** quando os valores se alteram, gerando assim um novo estado; - geralmente são criadas em par ```javascript= const [Variavel, setFunçãoQueAlteraAVariavel] = useState(valorInicial) ``` - Usar ```javascript= <div> {Variavel} </div> ``` **Podemos criar variaveis:** - Number. - String. - Boolean = não podem ser renderizadas, a menos que colocamos operadores {operador ternario}. ```javascript= ? 'sim' : 'Não' ``` - data = é renderizada apenas quando é convertida para string. - objeto = tem que chegar no nivel primitivo para ser renderizados, porém podemos usa-los em componentes. - array = convertar para componente usando a função map(pode ser renderizado, porém tudo fica grudado). - array objetos= não consegue renderizar. **concatenação = não precisa do operador +** ex: concatenação + array ```javascript= const [g, setG] = useState({ {nome: 'Laura', profissao:'Dev'} }) return( <div> {g[1].nome / {g[1.profissao]}} </div> ) ``` ## 7 **Props:** - Capacidade do react de permitir que um componente possa enviar informações para outro componente, e que o mesmo possa retornar informações (conversa entre componentes). - São os parametros da função *sempre que quiser referenciar uma variavel dentro de um codigo js ela deve estar dentro de {}.* ## 8 **Eventos:** - Capacidade do react de vincular funções a eventos que ocorrem no jsx. - onClik, onChange - O react não permite que você, chame uma função que altera o estado de uma variavel e logo em seguida chame uma função que estará usando esse valor atualizado. a não ser que use o useEffect ex: ```javascript= useEffect(() => { nome da função(); }, [variaveis que quer retornar]) ``` *Podemos criar efeitos que não monitoram ninguém, (efeitos iniciais)* ## 9 **Roteamento/passagem de paramentro:** - goBack: Voltar a pagina anterior - push - link *Podemos usar as funções link e push para redirecionar ou enviar parametros* *é possivel enviar objetos mais complexos usando o push ou o link* ## 10 **Eviar argumentos/propriedades para o styled-components** Ex: ```javascript= Const Container = styled.div` backgrund-color: ${props => props.corDoFundo} ` export default function Contact(props) { return( <container corDoFundo="#37E"> <div> Laura </div> </container> ) } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully