Search
⌘K
    to navigateEnterto select Escto close

    Prefer && over ?

    Let's start with code.

    1{lessonIds && lessonIds[lessonIds.length - 1] != lesson.id ? (
    2  <Button
    3    className="mx-2"
    4    label="Next"
    5    onClick={() => handleNextButton(lesson.id)}
    6   />
    7) : null}

    In the above case we can use && and that would make code more readable and we do not have to worry about returning a null.

    1{lessonIds && lessonIds[lessonIds.length - 1] != lesson.id && (
    2  <Button
    3    className="mx-2"
    4    label="Next"
    5    onClick={() => handleNextButton(lesson.id)}
    6   />
    7)}
    Previous
    Next