Advertisement
Guest User

Untitled

a guest
Jun 11th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useState, useEffect } from 'react'
  2. import './block.css'
  3.  
  4. let blockList = [
  5.   {
  6.     id: 1,
  7.     name: 'Test 1',
  8.   },
  9.   {
  10.     id: 2,
  11.     name: 'Test 2',
  12.   },
  13.   {
  14.     id: 3,
  15.     name: 'Test 3',
  16.   },
  17.   {
  18.     id: 4,
  19.     name: 'Test 4',
  20.   },
  21.   {
  22.     id: 5,
  23.     name: 'Test 5',
  24.   }
  25. ]
  26.  
  27. function Example() {
  28.  
  29.   let getElemList = blockList.map((elem, index) => {
  30.     return (
  31.       <div className="block-elem" key={index}>
  32.         { elem.name }
  33.       </div>
  34.     )
  35.   })
  36.   const [elemList, setElemList] = useState(getElemList);
  37.   function handleDown(e) {
  38.     e.preventDefault();
  39.     //console.log('Down: ', e.nativeEvent);
  40.     console.log(...elemList)
  41.  
  42.  
  43.   }
  44.   function handleUp(e) {
  45.     e.preventDefault();
  46.     //console.log('Up');
  47.   }
  48.   return (
  49.     <div>
  50.       <div className="block" onMouseDown={handleDown} onMouseUp={handleUp}>
  51.         { elemList }
  52.       </div>
  53.     </div>
  54.   )
  55. }
  56.  
  57. export default Example
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement