Why setState not set appending my array into state?

后端 未结 3 853
别跟我提以往
别跟我提以往 2021-01-27 03:11

I have to create a text area which taken multiple links then I split() into array yeah Its working fine, but I want to set that array into my state in

3条回答
  •  长情又很酷
    2021-01-27 03:29

    The below code might help.

    onSubmit = event => {
        this.setState({ loading: true, host: undefined }, () => {
          const { text, linkList } = this.state;
    
          console.log(link);
          const mList = text.split("\n").filter(String);
          console.log(mList);
          this.setState({
            linkList: [...mList]
          }, () => {
            console.log(linkList);
            event.preventDefault();
          });
        });
      };
    

提交回复
热议问题