dispatch proplem Uncaught (in promise) TypeError: dispatch is not a function

the code in product.jsx
the proplem is i want to update data but it doesnt work and i get this message in console Uncaught (in promise) TypeError: dispatch is not a function

export default function Product() {
      const [user,setUser]=useState({});
      const location = useLocation();
      const productId = location.pathname.split("/")[2];
      const [pStats, setPStats] = useState([]);
    
      const product = useSelector((state) =>
        state.product.products.find((product) => product._id === productId)
      );
     const handleChange =(e)=>{
        const value=e.target.value;
        setUser({
            ...user,
           [e.target.name]:value
        });
          };
          console.log(user)
    
      const dispatch = useDispatch();
     
      const handleclick=(id)=>{
        updateProduct(id,dispatch,user)
        console.log(id)
      }
    
      useEffect(() => {
        updateProduct(dispatch);
      }, [dispatch]);
      
      
    
      const MONTHS = useMemo(
        () => [
          "Jan",
          "Feb",
          "Mar",
          "Apr",
          "May",
          "Jun",
          "Jul",
          "Agu",
          "Sep",
          "Oct",
          "Nov",
          "Dec",
        ],
        []
      );
    
      useEffect(() => {
        const getStats = async () => {
          try {
            const res = await userRequest.get("order/income?pid=" + productId);
            const list = res.data.sort((a,b)=>{
                return a._id - b._id
            })
            list.map((item) =>
              setPStats((prev) => [
                ...prev,
                { name: MONTHS[item._id - 1], Sales: item.total },
              ])
            );
          } catch (err) {
            console.log(err);
          }
        };
        getStats();
      }, [productId, MONTHS]);
    
      return (
        <div className="product">
          <div className="productTitleContainer">
            <h1 className="productTitle">Product</h1>
            <Link to="/newproduct">
              <button className="productAddButton">Create</button>
            </Link>
          </div>
          <div className="productTop">
            <div className="productTopLeft">
              <Chart data={pStats} dataKey="Sales" title="Sales Performance" />
            </div>
            <div className="productTopRight">
              <div className="productInfoTop">
                <img src={product.img} alt="" className="productInfoImg" />
                <span className="productName">{product.title}</span>
              </div>
              <div className="productInfoBottom">
                <div className="productInfoItem">
                  <span className="productInfoKey">id:</span>
                  <span className="productInfoValue">{product._id}</span>
                </div>
                <div className="productInfoItem">
                  <span className="productInfoKey">sales:</span>
                  <span className="productInfoValue">5123</span>
                </div>
                <div className="productInfoItem">
                  <span className="productInfoKey">in stock:</span>
                  <span className="productInfoValue">{product.inStock}</span>
                </div>
              </div>
            </div>
          </div>
          <div className="productBottom">
            <form className="productForm">
              <div className="productFormLeft">
                <label>Product Name</label>
                <input type="text" placeholder={product.title} name="title" onChange={handleChange}/>
                <label>Product Description</label>
                <input type="text" placeholder={product.desc} name="desc" onChange={handleChange} />
                <label>Price</label>
                <input type="text" placeholder={product.price} name="price" onChange={handleChange} />
                <label>In Stock</label>
                <select name="inStock" id="idStock" onChange={handleChange}>
                  <option value="true">Yes</option>
                  <option value="false">No</option>
                </select>
              </div>
              <div className="productFormRight">
                <div className="productUpload">
                  <img src={product.img} alt="" className="productUploadImg" />
                  <label for="file">
                    <Publish />
                  </label>
                  <input type="file" id="file" style={{ display: "none" }} name="img" onChange={handleChange} />
                </div>
                <button className="productButton" onClick={(e)=>handleclick(product._id)}>Update</button>
              </div>
            </form>
          </div>
        </div>
      );
    }

code in apicalls (redux)

import {
  
  updateProductFailure,
  updateProductStart,
  updateProductSuccess,
  

} from "./productRedux";



export const updateProduct = async (id, product, dispatch) => {
  dispatch(updateProductStart());
  try {
    const res=await userRequest.patch(`/products/find/${id}`,product)
    
    dispatch(updateProductSuccess({ id, product }));
  } catch (err) {
    dispatch(updateProductFailure());
  }
};
}

code in product redux

export const productSlice = createSlice({
  name: "product",
  initialState: {
    products: [],
    isFetching: false,
    error: false,
  },
  reducers: {
 updateProductStart: (state) => {
      state.isFetching = true;
      state.error = false;
    },
    updateProductSuccess: (state, action) => {
      state.isFetching = false;
      state.products[
        state.products.findIndex((item) => item._id === action.payload.id)
      ] = action.payload.product;
    },
    updateProductFailure: (state) => {
      state.isFetching = false;
      state.error = true;
    },
}

i want to update my products by sending data from client to the api i think the proplem in the updateProductsucess function

How to dynamically display these data in a row?

How do I stack these data into something like this where each products and colors are in one row?
enter image description here

I did try with this, however, it ended up looking like this:
enter image description here

codesandbox:
https://codesandbox.io/s/responsivestack-material-demo-forked-330ogi?file=/demo.js

Codes:

{newProduct &&
        newProduct.map((item, i) => (
          <>
            <Stack
              key={i}
              direction={{ xs: "column", sm: "row" }}
              spacing={{ xs: 1, sm: 2, md: 4 }}
            >
              <Stack direction="row" spacing={2}>
                <ListItemText primary={item.prodName + " " + item.size} />
                Icon here ->
              </Stack>

              {Object.entries(item.colorMap).map((color) => (
                <>
                  <ListItemText secondary={`${color[0]} - ${color[1]}pcs`} />
                </>
              ))}
            </Stack>
          </>
        ))}

How to not reflect specific series in chart in apexchart

In series, I want to output the value as text above each bar without reflecting ‘ongoing’ data in the chart. I tried to hide series by setting [0, 1, 2, 3] in enabledOnSeries below, but it doesn’t work. All data except ‘ongoing’ data are numbers between 1 and 10, but ‘ongoing’ data consists of numbers between 20 and 200. Therefore, when outputting ongoing data as a stacked bar, data other than ‘ongiong’ is buried in the ground and cannot be seen well. And for visualization, I want the ‘ongoing’ data to be printed as text above each bar. Believe it or not, it took me 3 days to find a solution. If anyone knows about apexchart, please help me.

dataLabels: {
  enabled: true,
  enabledOnSeries: [1]
},

[dashboard.html]

<script>
var options3 = {
series: [
{
  name: 'I',
  data: {{ I | safe }}
}, {
  name: 'S',
  data: {{ S | safe }}
}, {
  name: 'P',
  data: {{ P | safe }}
}, {
  name: 'E',
  data: {{ E | safe }}
}, {
  name: 'ongoing',
  data: {{ ongoing | safe }}
},
],
chart: {
  type: 'bar',
  height: 550,
  stacked: true,
},
plotOptions: {
    bar: {
        dataLabels: {
            position: 'center',
        },
    }
},
dataLabels: {
    style: {
        fontSize: '10px',
        colors: ["#304758"]
    }
},
stroke: {
  width: 1,
  colors: ['#fff']
},
title: {
  text: 'I-S-P-E chart',
  offsetY: 0,
  align: 'center',
},
xaxis: {
  categories: {{ teacher | safe }},
},
yaxis: {
  title: {
    text: undefined
  },
},
fill: {
  opacity: 1
}
};

var chart3 = new ApexCharts(document.querySelector("#dashboard"), options3);
chart3.render();
</script >

How to upload a file in react typescript with drag and drop?

I am trying to code a drag and drop upload but the not getting anywhere with react typescript. I have a working example but the problem is in google dev tools it is not showing any file.

Here is the code

import { IoCloseSharp, IoChevronForward } from "react-icons/io5";
import { GoCloudUpload } from "react-icons/go";
import { DragEvent, SyntheticEvent } from "react";

type props = {
  onClose: any;
};

const AccountActionsModal = ({ onClose }: props) => {
  const onDropFile = (e: DragEvent) => {
    e.preventDefault();
    const f = e.dataTransfer as DataTransfer
    console.log(f.files);
  };

  return (
    <>
      
            <form>
              <div className="AAFileInput">
                <label
                  htmlFor="Picture"
                  id="AAFileUpload"
                  onDrop={onDropFile}
                  onDragOver={(e) => {
                    e.preventDefault();
                  }}
                  onDragEnter={(e) => {
                    e.preventDefault();
                  }}
                >
                  <GoCloudUpload size={40} />
                  <br />
                  Upload File
                  <br />
                  <span style={{ color: "grey" }}>Drag and Drop</span>
                </label>

                <input type="file" name="Picture" id="Picture" />
              </div>
            </form>
          
    </>
  );
};

export default AccountActionsModal;

You can see I log the filelist but there is no files in the console. It shows 0. I have searched for answers some say that this is a bug in dev tools. because when I log just the event then also it shows 0 files.

FileList {length: 0}

Please help me figuring this out.

How to retrieve a particular value from json [duplicate]

{
"analysisUnits": [
{
  "links": [
    {
      "rel": "self"
    }
  ],
  "name": "MI5-WES7",
}
],
 "name": "MTS Recording Cluster",
 "recordingUnits": [
{
  "activePCIeExt": false,
  "dataBlocking": false,

  "links": [
    {
      "rel": "self"
    }
  ],
  "name": "MI5-WES7 #5192 radar-mi",
  "recDriveFull": false,
  "recDriveSpaceLow": false,
  }
  {
  "activePCIeExt": false,
  "dataBlocking": false,
  "links": [
    {
      "rel": "self"
    }
  ],
  "name": "OZD1457W #191 radar-mi",
  "recDriveFull": false,
  }]

Here in the above json, I want to get the value present under recording units “name”: “MI5-WES7 #5192 radar-mi”, in the above name I want only the number after #, which is 5192 should be stored with corresponding name radar-mi in an array. similarly there is another device with “name”: “OZD1457W #191 radar-mi”. So it should check for the no of such recording units present and store its values in array.

Zendesk authentication

I need to display user’s name in the in the zendesk chat ( for the agents), I’m using the code provided by zendesk:

window.zESettings = {
 webWidget: {
   authenticate: {
     chat: {
       jwtFn: function(callback) { 
         fetch('JWT_TOKEN_ENDPOINT').then(function(res) {
            res.text().then(function(jwt) {
             callback(jwt);
            });
          });
        }
      } 
    }
  }
};

and jwt token is:

var payload = {
  name: '#{customerName}',
  email: '#{customerEmail}',
  iat: #{timestamp},
  external_id: '#{externalId}'
};
var token = jwt.sign(payload, '#{yourSecret}');

The code doesn’t work, I don’t get errors but user name is not visible. Zendesk documentation doesn’t provide any valuable information, has anyone integrated Zendesk in their app? What am I doing wrong? any help and suggestion is greatly appreciated.

Update an item inside a document’s array

I have a model that looks like this:

const List = new Schema({
    name: { type: String, unique: true, required: true, dropDups: true },
    cards: [{ type: Schema.Types.ObjectId, ref: 'Card' }],
    orderItems: [{ value: Number, card: { type: Schema.Types.ObjectId, ref: 'Card' } }]
});

And a document base of that model that looks like this:

{ _id: ObjectId: ("1234567890"), cards: [...], OrderItems: [{ card: ObjectId: ("0987654321"), value: 1.1, _id: ObjectId: ("1029384756") }] }

I want to update the value of the only object that’s in the OrderItem’s array of my document, I tried the most obvious methods like:

doc.OrderItems[0].value = 1.2;
doc.save();

but that’s not working, how can I do it?

RegEx Returning null when trying to match . Why?

I’ve created this example to illustrate what the RegEx is intended to match.

As you can see, the string remains the same through out all conversions, then when it gets to RegEx, it fails.

It appears the RegEx is matching everything literally instead of perceiving as a null character to match. I’m not sure why.

If you run the RegEx against a string variable that contains user1letmein, it returns true and string array of values.

Take a look:

// SOURCE
const sourceDataLiteral = `user1letmein`;
console.log('sourceDataLiteral:', sourceDataLiteral, 'length:', sourceDataLiteral.length);

// SOURCE BINARY
const sourceDataBinary = new TextEncoder().encode(sourceDataLiteral);
console.log(sourceDataBinary);

// ENCODE TO BASE64
const base64DataEncoded = btoa(sourceDataLiteral);
console.log('base64DataEncoded:', base64DataEncoded, 'length:', base64DataEncoded.length);

// DECODE FROM BASE64
const base64DataDecoded = atob(base64DataEncoded);
console.log('base64DataDecoded:', base64DataDecoded, 'length:', base64DataDecoded.length);

// DECODED BINARY
const decodedDataBinary = new TextEncoder().encode(base64DataDecoded);
console.log(decodedDataBinary);

// RegEx MATCH userpassword
const CREDENTIALS = /^([\0]{1}w+)([\0]{1}w+)$/.exec(base64DataDecoded);

// Why does it return null? (Meaning, NO MATCH.)
console.log(CREDENTIALS);

Mongoose aggregate does find a random document from the DB but why can’t I push it onto an object array?

workout is declared earlier (const workout = new Workout …)
The models are required. I’ve successfully pushed moves to the workout model when using .findOne (so I know it’s not the schemas)

Here, when I console.log core, it does return a random move object from the right category, but when I try to push it onto workout.moves I get a cast error, “CastError: Cast to ObjectId failed for value” then the core move object that I’ve found and am trying to push.

const core = await Move.aggregate([ {$match: {category: “core”}}, {$sample: {size: 1}}]);
console.log(core)

workout.moves.push(core)

The found core move has an object ID, and it’s worked to push moves from the moves database to the workout objects before using .find or .findOne. I’m sure there’s something I’m missing, and this is the first time I’ve used .aggregate but I’ve been searching and moving things around for ages and can’t find it.

I’ve also tried destructuring the id (const {id} = core) but it comes up null when I console.log it.

How can I parse this object to get back the name of the object?

I am trying to filter out only the textfields out of a giant object… but I am having trouble getting the name of the object to show.

This is the giant object:

[
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 6, generationNumber: 0, tag: '6 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 7, generationNumber: 0, tag: '7 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 8, generationNumber: 0, tag: '8 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 9, generationNumber: 0, tag: '9 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 10, generationNumber: 0, tag: '10 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 11, generationNumber: 0, tag: '11 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 12, generationNumber: 0, tag: '12 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 13, generationNumber: 0, tag: '13 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 14, generationNumber: 0, tag: '14 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 15, generationNumber: 0, tag: '15 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 16, generationNumber: 0, tag: '16 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 17, generationNumber: 0, tag: '17 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 18, generationNumber: 0, tag: '18 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFTextField {
    acroField: PDFAcroText { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 19, generationNumber: 0, tag: '19 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  },
  PDFDropdown {
    acroField: PDFAcroComboBox { dict: [PDFDict], ref: [PDFRef] },
    ref: PDFRef { objectNumber: 20, generationNumber: 0, tag: '20 0 R' },
    doc: PDFDocument {
      defaultWordBreaks: [Array],
      computePages: [Function (anonymous)],
      getOrCreateForm: [Function (anonymous)],
      context: [PDFContext],
      catalog: [PDFCatalog],
      isEncrypted: false,
      pageCache: [Cache],
      pageMap: Map(0) {},
      formCache: [Cache],
      fonts: [],
      images: [],
      embeddedPages: [],
      embeddedFiles: [],
      javaScripts: []
    }
  }
]

When I do a console log of the following object, this is what I get:

console.log(fields1[0])


PDFTextField {
  acroField: PDFAcroText {
    dict: PDFDict { dict: [Map], context: [PDFContext] },
    ref: PDFRef { objectNumber: 6, generationNumber: 0, tag: '6 0 R' }
  },
  ref: PDFRef { objectNumber: 6, generationNumber: 0, tag: '6 0 R' },
  doc: PDFDocument {
    defaultWordBreaks: [ ' ' ],
    computePages: [Function (anonymous)],
    getOrCreateForm: [Function (anonymous)],
    context: PDFContext {
      largestObjectNumber: 44,
      header: [PDFHeader],
      trailerInfo: [Object],
      indirectObjects: [Map],
      rng: [SimpleRNG]
    },
    catalog: PDFCatalog { dict: [Map], context: [PDFContext] },
    isEncrypted: false,
    pageCache: Cache { populate: [Function (anonymous)], value: undefined },
    pageMap: Map(0) {},
    formCache: Cache { populate: [Function (anonymous)], value: [PDFForm] },
    fonts: [],
    images: [],
    embeddedPages: [],
    embeddedFiles: [],
    javaScripts: []
  }
}

I have tried doing Object.keys(fields1[0])

but all I get is [ ‘acroField’, ‘ref’, ‘doc’ ]

Displaying a nested data with a conditional: How can I not display the data whose product’s color is not according to the conditional?

I am trying to display all the quantity of colors that are more than 10. It does display it, however, this will also display even the products whose colors are less than 10. How do I fix this? Thank you.

codesandbox: https://codesandbox.io/s/products-0ccdhk?file=/src/App.js:752-1189

 {product &&
        product.map((item, i) => (
          <ul key={i}>
            <li>{item.id}</li>
            <li>{item.prodName + " " + item.size}</li>
            {Object.entries(item.colorMap).map((color) => (
              <>
                {color[1] > 10 && (
                  <>
                    {color[0]} - {color[1]}
                  </>
                )}
              </>
            ))}
          </ul>
        ))}

Currently, this is what it looks like:

enter image description here

Google maps, call function ONLY after dragging map (not zooming)

So this is working for dragging around on the map but it’s a little too sensitive (if I scroll zoom on the map it calls the function too, and also if I trigger a map marker, which changes the center of the map, it gets called)

So with this working bit of code, how can I refine this to truly only call my searchByState function after dragging around on the map and not when zooming or triggering a marker?

google.maps.event.addListener(map,'idle',function(){
          if(!this.get('dragging') && this.get('oldCenter') && this.get('oldCenter')!==this.getCenter()) {
            var lat = map.getCenter().lat();
            var lon = map.getCenter().lng()

            searchByState(lon,lat);
          }
          if(!this.get('dragging')){
           this.set('oldCenter',this.getCenter())
          }

        });

        google.maps.event.addListener(map,'dragstart',function(){
          this.set('dragging',true);          
        });

        google.maps.event.addListener(map,'dragend',function(){
          this.set('dragging',false);
          google.maps.event.trigger(this,'idle',{});
        });