Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

delete request reaxt

import React from "react";

const arr = [
  { id: 1, name: "apple" },
  { id: 2, name: "orange" },
  { id: 3, name: "grape" }
];

export default function App() {
  const [items, setItems] = React.useState(arr);

  const deleteItem = (index) => () =>
    setItems((items) => items.filter((_, i) => i !== index));

  return (
    <>
      {items.map((it, index) => {
        return (
          <div key={it.id}>
            {it.name} <button onClick={deleteItem(index)}>delete</button>
          </div>
        );
      })}
    </>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to search and filter js 
Javascript :: node.js http server 
Javascript :: javascript add maxlength attribute 
Javascript :: how to fetch api in class component react 
Javascript :: js multiline string with variables 
Javascript :: box shadow generador react native 
Javascript :: selectores de jquery 
Javascript :: javascript example 
Javascript :: javascript rest 
Javascript :: updatedAt mongoose stop 
Javascript :: AJAX - Server Response 
Javascript :: react composition 
Javascript :: angular add ellipsis to template string 
Javascript :: regex checker 
Javascript :: pass value inside the js file using script tag 
Javascript :: [Object: null prototype] appolo 
Javascript :: greater than or equal to javascript 
Javascript :: vuejs get data fromo ajax 
Javascript :: npm node size 
Javascript :: eval in javascript 
Javascript :: reset event listener javascript 
Javascript :: class in javascript 
Javascript :: send data using axios 
Javascript :: remove in javascript 
Javascript :: check if something is a letter in js 
Javascript :: express get raw query 
Javascript :: use the AJAX XMLHttpRequest object in Javascript to send json data to the server 
Javascript :: promise in es6 
Javascript :: download file from api response 
Javascript :: react route path 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =