State in React code is not working

Getting error when I add useState function in productItem.js file.


Code in ProductItem.js
import ‘./ProductItem.css’;
import React, { useState } from ‘react’

function ProductItem(props) {

const [changeText, setText] = useState(props.type)

function clickHandler(){
    setText('Added to Cart')
}
return(
{props.name}

{changeText}

{props.price}
Add to Cart
);

}
export default ProductItem;

@Shizuka You code should look like this:

The elements you are returning in the function are invalid and can not be rendered on the web page.

Thank you. It’s working now.