如何更改useState儿童的数据?

问题描述

READ: mov eax,3        ; choose sys_read
          mov ebx,0        ; file descriptor stdin 
          mov ecx,Buffer       ; pass address of buffer
          mov edx,BUFFER_LENGTH    ; set buffer length 
          int 80h           ; call read()
          cmp eax,0        ; check if there is error reading
          jb EXIT           ; if -1 exit
          je EXIT           ; if  0 exit
    
    mov esi,eax            ; safe keeping number of bytes_read
    dec esi         ; adjust offset
    mov ebp,Buffer     ; Store address of Buffer in ebp
    add ebp,esi            ; ebp Now point to it's buffer end
    
        ; Now Start The Loop and Change Characters Needed

    LOOP: cmp byte[ebp],61h    ; Check if it's equal to 'a'
          jb NEXT           ; GO to Next Character 
          cmp byte[ebp],7Ah    ; Check if it's equal to 'z'
          ja NEXT           ; Go to next Character
          
          sub byte[ebp],20h    ; ELSE convert to uppercase then go to next automatically
                 
     NEXT: dec esi          ; Decrement esi 'Counter'
           dec ebp          ; Decryment ebp "to point to previous Character"
           jnz LOOP     ; Go To the loop again to check Next Character until ZERO
           
           ; Once Reached Zero The ZF flag is set and write complete as Normal

    WRITE: mov edx,eax ; pass how many bytes to be written
           mov eax,4   ; specify sys_write call
           mov ebx,1   ; specify file descriptor
           mov ecx,Buffer  ; pass buffer address "changed letter"
           int 80h      ; make write call
           jmp READ ; Go to read again to read NEXT Chunk
           
     EXIT: mov eax,1   ; specify sys_exit
           mov ebx,0   ; specify return value
               int 80h      ; make sys_exit call

如何使用setBlocks将“数据”更改为“这是其他一些数据”?

解决方法

useState的设置方法不仅接受数据,还接受函数。

setState(prevState => {
  return {...prevState,...updatedValues};
});

因此您可以编写类似这样的内容。

setBlocks(prevState => ({
  ...prevState,blocks: prevState.blocks.map(v => {
    return (v.key === 1)
      ? {...v,data: 'this is some other data'}
      : v;
  }),});

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...