LogoLogo
Class SchedulesOfficial WebsiteMigraCode SyllabusHow to teach tech
  • 👩‍🏫Welcome to the MigraCode Volunteer Guide
  • General information
    • ℹ️About MigraCode
    • 🖱️Working with our students
    • 👥Volunteering roles
      • Teaching volunteer roles
      • Mentoring volunteer roles
      • Slack volunteer roles
  • Teaching instructions
    • 🖥️Basic computer literacy
      • Lesson 1: Introduction and Browser
      • Lesson 2: More browsing and Internet
      • Lesson 3: Mail and a taste of Drive
      • Lesson 4: Google Docs
      • Lesson 5: Google sheets
      • Lesson 6: Google slides
    • 👩‍💻Web development
      • Class Example
      • Teaching instructions
        • Introduction
          • 1 - Terminal and Visual Code
          • 2 - Git and Github
        • HTML/CSS
          • 1 - Semantic HTML and CSS
          • 2 - Responsive Web and layout
          • 3 - Bootstrap
        • JavaScript I
          • 1 - Hello Javascript
          • 2 - Expressions and loops
          • 3 - Arrays and callbacks
        • Javascript II
          • 1 - Javascript in the browser
          • 2 - Objects
          • 3 - Introduction to APIs
        • Javascript III
          • 1 - HTTP Protocols and ES6
          • 2 - Workshop Part 1
          • 3 - Workshop Part 2
        • React
          • 1 - Hello React
          • 2 - Reacting to changes
          • 3 - Fetching Data
        • NodeJS
          • 1 - Node and Express 101
          • 2 - APIs in Node
          • 3 - Workshop
        • Databases
          • 1 - Introduction to SQL
          • 2 - SQL with Node
          • 3 - CRUD with SQL and Node
    • 🛠️Professional Skills
      • Module 1: Soft skills
      • Module 2: Employability
      • Module 3: Working in projects
  • Useful Links
  • Class Schedules
  • Official Website
  • MigraCode Syllabus
  • How to teach tech
Powered by GitBook
On this page
  • Notes for Instructors
  • Homework Suggestion
  • Practice Day (Saturday)
  • Feedback

Was this helpful?

Export as PDF
  1. Teaching instructions
  2. Web development
  3. Teaching instructions
  4. React

2 - Reacting to changes

Notes for Instructors

Handling Events

  • Function references vs function calls is a very common source of confusion

    • It is worth recapping again to ensure that students really do understand it

  • Passing event handler function references

    • The concept trips up a lot of students - will try to immediately call the function when passing to an event handler e.g. onClick={this.foo()}

  • Passing functions as props

    • This concept isn't really that much different from the section above, but passing across components does often confuse students

Re-Rendering Components

  • The goal of this section is to demonstrate React re-rendering but without using state

    • i.e. showing that React will call component functions again to get updated JSX after props/state changes

    • Teaching separately allows us to emphasise that setting state has 2 jobs: updating the state and triggering React to re-render

    • It is also convenient to (briefly) discuss how the virtual DOM is efficient

  • Re-rendering demo

    • Focus on the Counter component primarily, in particular the console.log

    • The code in index.js is just a way of forcing a re-render without using state. But we don't really want students to learn the bad habits here (we want them to ultimately learn state), so they are hidden away.

State

  • This section takes a bit of a risk - it deliberately shows the wrong way trying to do state, then refactors to fix it

  • Before fixing the problem, something to emphasise is the moment when we start using the virtual DOM for the first time

    • When we trigger a manual re-render to ReactDOM.render()

    • But we are updating the DOM here - we mentioned in lesson 1 that this was hard, and now we've got an easy way of updating it. This is the true power of React

  • We cover the problems with using a global variable, so hopefully that is enough to prevent the students copy/pasting the wrong way

    • Ensure that you emphasise this is the wrong way to do state

  • Demonstrate the app with multiple counters

    • Shows that each components remembers their own state separate to other components

  • When to use props or state?

    • My rule of thumb: use props until you need it to change over time, then switch to state

Homework Suggestion

  1. If unfinished, complete the in-class exercises on your pokedex app

Practice Day (Saturday)

Feedback

Previous1 - Hello ReactNext3 - Fetching Data

Last updated 4 years ago

Was this helpful?

Remember copy the Homework to the at the end of the class

Complete all of the lesson 2 of project

Live coding session with students to go over project lession 2 steps and Q&A session to clear their doubts.

We can always improve thanks to your feedback, you can use this document to send your ideas or suggestions on every week. This will help us to improve Syllabus and this guide

👩‍💻
Trello
cyf-hotel-react
cyf-hotel-react
document