How to map over and return items in localStorage?

  javascript, reactjs

I currently have items in local storage, the console.log of data currently in local storage looks like this:

enter image description here

I want to simply map through these items and render the titles. I thought the below code would work, but nothing is being displayed, and I have no error messages. Do you know what I am doing wrong? Thank you.

import React, { useState, useEffect } from 'react';
import './../App.css';
import * as ReactBootStrap from 'react-bootstrap';
import {Link} from 'react-router-dom';

function Cart() {

const storageItems = JSON.parse(localStorage.getItem('product'));
console.log(storageItems)

    return (
      <div className="App">
          {storageItems.map((item) => {
            <p>item.title</p>
          })}
      </div>
    );
}

export default Cart;

Source: Ask Javascript Questions

LEAVE A COMMENT