How to render LISTS in React 📃

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ส.ค. 2024
  • 00:00:00 List component setup
    00:00:36 array of strings
    00:03:33 array of objects
    00:05:21 key.id
    00:07:02 sort objects
    00:09:55 filter objects
    00:12:18 resusable List component
    00:16:28 CSS styling
    00:19:43 conditional rendering
    00:21:44 defaultProps
    00:23:19 propTypes

ความคิดเห็น • 45

  • @BroCodez
    @BroCodez  9 หลายเดือนก่อน +15

    import List from './List.jsx'
    function App() {
    const fruits = [{id: 1, name: "apple", calories: 95},
    {id: 2, name: "orange", calories: 45},
    {id: 3, name: "banana", calories: 105},
    {id: 4, name: "coconut", calories: 159},
    {id: 5, name: "pineapple", calories: 37}];
    const vegetables = [{id: 6, name: "potatoes", calories: 110},
    {id: 7, name: "celery", calories: 15},
    {id: 8, name: "carrots", calories: 25},
    {id: 9, name: "corn", calories: 63},
    {id: 10, name: "broccoli", calories: 50}];
    return(
    {fruits.length > 0 && }
    {vegetables.length > 0 && }
    );
    }
    export default App
    import PropTypes from 'prop-types';
    function List(props){
    const category = props.category;
    const itemList = props.items;
    //itemList.sort((a, b) => a.name.localeCompare(b.name)); // SORT ALPHABETICAL
    //itemList.sort((a, b) => a.calories - b.calories); // SORT BY CALORIES
    //const lowCalItem = itemList.filter(item => item.calories < 100); // FILTER LOW CALORIES
    //const highCalItem = itemList.filter(item => item.calories >= 100); // FILTER HIGH CALORIES
    const listItems = itemList.map(item =>
    {item.name}:  
    {item.calories});

    return(
    {category}
    {listItems}
    );
    }
    List.propTypes = {
    category: PropTypes.string,
    items: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.number,
    name: PropTypes.string,
    calories: PropTypes.number})),
    }
    List.defaultProps = {
    category: "Category",
    items: [],
    }
    export default List
    .list-category{
    font-size: 2.5em;
    font-weight: bold;
    color: hsl(0, 0%, 20%);
    margin-bottom: 10px;
    text-align: center;
    border: 3px solid;
    border-radius: 5px;
    background-color: hsl(185, 100%, 50%);
    }
    .list-items li{
    font-size: 2em;
    list-style: none;
    color: hsl(0, 0%, 25%);
    text-align: center;
    margin: 0;
    }
    .list-items li:hover{
    color: hsl(0, 0%, 45%);
    cursor: pointer;
    }

    • @tee-hee9553
      @tee-hee9553 9 หลายเดือนก่อน +1

      teacher, why we need to do those stuff like download npm create npm create vite@latest npm install, npm run dev, I see on other website they only import react like react/client or something, so when create an web application do we need to use import or create my-react-app and run I don't really understand about this it's confuse me I though I learn in a wrong way so confuse please if you have time answer me

  • @v.a2282
    @v.a2282 9 หลายเดือนก่อน +7

    I learnt javascript from u and I was looking forward to learning react and u started making this series right then!! Thank you so much bro u have changed my life by making programming so interesting! Your hard work is very much appreciated

  • @leivashenriquedelucenaaqui1126
    @leivashenriquedelucenaaqui1126 7 หลายเดือนก่อน +2

    the best teacher ever!!!!!!!!!!!!!!!!!!!!!!!!!! thanks from brazil, we all aprecciate your classes!!!! you're born to teach!!!

  • @lyawileh.a8741
    @lyawileh.a8741 10 วันที่ผ่านมา

    Best instructor ever! You've made learning React a breeze.

  • @GRAVKEN
    @GRAVKEN 9 หลายเดือนก่อน

    Thank you , I really searched a lot for a good and entertaining tutorial about listing in specific!

  • @Waltuh7862
    @Waltuh7862 9 หลายเดือนก่อน +14

    Bro, I found your videos recently and they’ve been a godsend for me while studying in school and building my portfolio. I wanted to ask, have you considered doing a series on API’s?

    • @natureshour499
      @natureshour499 9 หลายเดือนก่อน +3

      He is too amazing bro I love his affords a lot because no 1 in youtube is providing so much of perfect education course for free.I love bro code ❤

    • @Raghad-hy9cr
      @Raghad-hy9cr 8 หลายเดือนก่อน +2

      Totally agree! He is amazing at breaking down complex concepts into understandable ones, and API’s have a really bad learning curve (at least for me)😢.
      it needs someone like him to explain it in order for me to understand it

  • @shreehari2589
    @shreehari2589 9 หลายเดือนก่อน +17

    Since you already have JavaScript course can you upload react videos more often please, I think lot of people are waiting for react videos

  • @Neatta2
    @Neatta2 9 หลายเดือนก่อน

    Thanks bro for your efforts, I learned alot from you 😁

  • @TheLaidBackOne02015
    @TheLaidBackOne02015 9 หลายเดือนก่อน +1

    Bro code, you're the absolute goat!

  • @WandaNice-o7s
    @WandaNice-o7s 9 วันที่ผ่านมา

    heyyy this tutorial is very helpful!!! thanks

  • @ayMillmusic
    @ayMillmusic 4 หลายเดือนก่อน

    Great video! Thanks!

  • @Gabriel-yf8ke
    @Gabriel-yf8ke 9 หลายเดือนก่อน

    Thanks! Really useful!

  • @enescagrbayraktutan6329
    @enescagrbayraktutan6329 9 หลายเดือนก่อน

    You are a beast bro, keep up the good work man! please focus more on this course instead of javascript

  • @latifmoruf6720
    @latifmoruf6720 29 วันที่ผ่านมา

    Excellent concept of teaching

  • @unsjvr
    @unsjvr 9 หลายเดือนก่อน +1

    can't wait for the tutorial about hooks. I've watched a lot of tutorials about react hooks but still could not grasp it 😭

  • @max0206may
    @max0206may 3 หลายเดือนก่อน

    @BroCodez Nice content ;) - Thanks I really appreciate your work and dedication

  • @hunin27
    @hunin27 9 หลายเดือนก่อน

    thanks Bro !!! ❤

  • @user-uv4zu8rv5o
    @user-uv4zu8rv5o 6 หลายเดือนก่อน

    thanks u make my life easy bro

  • @danielmelek9348
    @danielmelek9348 9 หลายเดือนก่อน

    Bro you are the real MVP 💐💐

  • @owenerhabor
    @owenerhabor 9 หลายเดือนก่อน +2

    You're the best !!!

  • @NapoleanBonaparte-bv2hz
    @NapoleanBonaparte-bv2hz 9 หลายเดือนก่อน

    Thanks a lot, now please upload the full version of react tutorial like you did with the rest.

    • @RockySharma-gp5th
      @RockySharma-gp5th 9 หลายเดือนก่อน

      I'm also waiting for full video

  • @life_with_rauf
    @life_with_rauf 9 หลายเดือนก่อน

    which os yuh using bro

  • @Jamal_Almansoub
    @Jamal_Almansoub 9 หลายเดือนก่อน +1

    😂a random comment😂
    I don't know "React"
    But I learn "Java"
    And like your videos

  • @Divine_2468
    @Divine_2468 9 หลายเดือนก่อน

    Bro Code, I just wanted to ask if you could make a video on kivy. I would really appreciate that if you are able to.

  • @SoapCS2
    @SoapCS2 9 หลายเดือนก่อน

    React full course coming?

  • @thangavel_st
    @thangavel_st 9 หลายเดือนก่อน

  • @natureshour499
    @natureshour499 9 หลายเดือนก่อน

    Bro code i am your big fan bro just 1 request i know it will be hard but if you will get time than please can you upload the video of Cypher security full course bro because its full course fee is too high bro, its not any pressure because i can understand bro in our daily life we don't get time but still if you can do it little by little than please have a look on it brother thankyou ❤

  • @danishsaifi7817
    @danishsaifi7817 9 หลายเดือนก่อน

    I don't know anything about react but i am first here 😂❤

    • @BalisticTester
      @BalisticTester 9 หลายเดือนก่อน

      nope you are not

  • @Delicatamente
    @Delicatamente 3 หลายเดือนก่อน

    huge thanks!

  • @danialalfayyadh2524
    @danialalfayyadh2524 7 หลายเดือนก่อน

    Maybe I Got Error at 3:10 and I search the answer and I got the answer like this :
    function List() {
    const fruits = ["Apple", "Banana", "Coconut", "Pineapple", "Salak"];
    const listItems = fruits.map(fruit => {fruit});
    return (

    {listItems}

    );
    }
    export default List;
    And That's Work

  • @sakiasibaleiwaikomai
    @sakiasibaleiwaikomai 5 หลายเดือนก่อน

    Upload more please

  • @DarkM999
    @DarkM999 9 หลายเดือนก่อน

    we need video for rust programming language

  • @utilizator500
    @utilizator500 9 หลายเดือนก่อน

    Ok now do Angular pls

  • @hellomihai
    @hellomihai 6 หลายเดือนก่อน

    he was saying *lowCalFruit*... I thought he was saying *localeFruit*... I need a break 🤣

  • @adamgamer1711
    @adamgamer1711 9 หลายเดือนก่อน

  • @abududivine6345
    @abududivine6345 9 หลายเดือนก่อน

    First

  • @nebularzz
    @nebularzz 9 หลายเดือนก่อน

    im tired and i read the title as "how to racist" when it appeared in my notifications

    • @peaklegacy146
      @peaklegacy146 8 หลายเดือนก่อน +1

      accidently went back to default settings for a second😂

  • @uff_statuss_
    @uff_statuss_ 4 หลายเดือนก่อน

    category used for ???? @BroCodez