Home > Blockchain >  if condition is not working React 17 version
if condition is not working React 17 version

Time:12-28

import React from 'react'

export const Pending = ({ items, setItems, updateStatus }) => {

    

    return (
        <div className="pending">
            <h1>Pending</h1>

            {
                items && items.map(item => {
                    if (item && item.status === 'Pending')
                        return <>
                            <p className="item" key={item.id}>
                                {item.title}
                                <button className="mark_complete" key={item.id} onClick={() => { updateStatus(item.id, 'Completed') }}>Mark Complete</button>
                            </p>
                        </>
                })
            }

        </div>
    )
}

if condition is working in react version 18 but not working in version 17. Can anybody help how to change this code to version 17

CodePudding user response:

As per enter image description here

That's how you perform conditional rendering in JSX.

  • Related