Syntax error: Unexpected token error

I’m getting attached error while running the code Chrome development tool

Here is the code

import { useState } from "react";

export function useLocalStorage (key, defaultValue){
    const getInitialValue = () => localStorage.getItem(key) ?? defaultValue;
    const [value,setValue] = useState(getInitialValue);
    const SetAndStoreValue = (newvalue) => {
    return [value,SetAndStoreValue];


You’re using React, yet you posted to the Ionic v3 subforum. I don’t think Ionic had React support in v3, so this is a bit of a weird question. Based only on your topic title and code (I guess you probably also posted an image, but I don’t see it), I’m going to guess that you’re using a version of TypeScript <3.7, when the nullish coalescing operator (??) was introduced.