Code Monkey home page Code Monkey logo

cs50m--lecture-5's Introduction

LECTURE 5 - Lists & User input

Lists

● In web, browsers will automatically become scrollable for content with heights taller than the window
● In mobile, we need to do that manually. We can do that using the following Components from React Native
      ○ ScrollView
      ○ ListView (deprecated)
      ○ FlatList, SectionList

ScrollView

● The most basic scrolling view
● I renders all of its children before appearing
● To render an array of data, we can use .map()
     ○ Components in an array need a unique key prop
REF 👉🏿 https://facebook.github.io/react-native/docs/scrollview.html

FlatList

● A performant scrolling view for rendering data
● “Virtualized:” only renders what’s needed at a time
     ○ Only the visible rows are rendered in first cycle
     ○ Rows are recycled, and rows that leave visibility may be unmounted
● Pass an array of data and a renderItem function as props
● Only updates if props are changed
     ○ Immutability is important
REF 👉🏿 https://facebook.github.io/react-native/docs/flatlist.html

SectionList

● Like FlatList with additional support for sections
● Instead of data prop, define sections
     ○ Each section has its own data array
     ○ Each section can override the renderItem function with their own custom renderer
● Pass a renderSectionHeader function for section headers
REF 👉🏿 https://facebook.github.io/react-native/docs/sectionlist.html

CONTINUES TO LECTURE 5 - User input & Debugging

User Input

● Controlled vs uncontrolled components
     ○ Where is the source of truth for the value of an input?
● React recommends always using controlled components
● Pass value and onChangeText props
REF 👉🏿 https://facebook.github.io/react-native/docs/textinput.html

Live Demo

This simple phone book App has been hosted in my Expo snacks

⚙️ Project page: https://snack.expo.dev/@qbentil/lecture-5---contacts

cs50m--lecture-5's People

Contributors

qbentil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  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.