title: How can i set data in state in reactjs
body: <p>Since i am new in react,i used filter and map to select array from array list.I got my output as expected.Now i want to set this.state.search by rendered value.How can i do it?
  Here are the pictures of my code below:</p>
  
  <pre><code>import React, { Component } from 'react';
  import { NativeSelect } from '@material-ui/core';
  
  export default class Test extends Component {
  constructor() {
      super();
      this.state = {
          people: [
              {
                  address: "Biratnagar",
  
                  bank: "Nabil Bank",
  
                  bankaccountnumber: 34343434,
  
                  baselocation: "Kathmandu",
  
                  basicpay: 5000,
  
                  branch: "telecom",
  
                  class: "class1",
  
                  confirmpassword: "nabanit123",
  
                  degree: "master",
  
                  designation: "engineer",
  
                  email: "nabanitkoirala@gmail.com",
  
                  id: "5e9fdebf0178920ed082241f",
  
                  mobilenumber: 445454545,
  
                  name: "Nabanit Koirala",
  
                  password: "nabanit123",
  
                  salary: 20000
              },
              {
                  address: "Biratnagar",
  
                  bank: "Nabil Bank",
  
                  bankaccountnumber: 34343434,
  
                  baselocation: "Kathmandu",
  
                  basicpay: 5000,
  
                  branch: "telecom",
  
                  class: "class1",
  
                  confirmpassword: "nabanit123",
  
                  degree: "master",
  
                  designation: "engineer",
  
                  email: "nabanitkoirala@gmail.com",
  
                  id: "5e9fdebf0178920ed082241f",
  
                  mobilenumber: 445454545,
  
                  name: "saroj kumar",
  
                  password: "nabanit123",
  
                  salary: 30000
              },
              {
                  address: "Biratnagar",
  
                  bank: "Nabil Bank",
  
                  bankaccountnumber: 34343434,
  
                  baselocation: "Kathmandu",
  
                  basicpay: 5000,
  
                  branch: "Account",
  
                  class: "class1",
  
                  confirmpassword: "nabanit123",
  
                  degree: "master",
  
                  designation: "engineer",
  
                  email: "nabanitkoirala@gmail.com",
  
                  id: "5e9fdebf0178920ed082241f",
  
                  mobilenumber: 445454545,
  
                  name: "kamlesh shresths",
  
                  password: "nabanit123",
  
                  salary: 5000
              },
              {
                  address: "Biratnagar",
  
                  bank: "Nabil Bank",
  
                  bankaccountnumber: 34343434,
  
                  baselocation: "Kathmandu",
  
                  basicpay: 5000,
  
                  branch: "IT",
  
                  class: "class1",
  
                  confirmpassword: "nabanit123",
  
                  degree: "master",
  
                  designation: "engineer",
  
                  email: "nabanitkoirala@gmail.com",
  
                  id: "5e9fdebf0178920ed082241f",
  
                  mobilenumber: 445454545,
  
                  name: "kumar thapa",
  
                  password: "nabanit123",
  
                  salary: 50000
              },
          ],
          name: '',
          isLoading: true,
          search: ''
      }
  }
  handleChange = (e) =&gt; {
      const { name, value } = e.target;
      this.setState({
          [name]: value
      })
  }
  handleSubmit = (e) =&gt; {
      e.preventDefault();
  
      this.setState({
          isLoading: false
  
  
      })
  
      console.log("handle submit&gt;&gt;", this.state);
  }
  componentDidMount() {
      this.setState({
          search: Test
      })
  
  }
  
  render() {
      console.log("component did mount&gt;&gt;", this.state);
      const { search } = this.state;
      let Test = this.state.isLoading
          ? &lt;p&gt;Isloading&lt;/p&gt;
          : this.state.people.filter(item =&gt; item.name === this.state.name).map(item =&gt; (
              &lt;div&gt;
                  &lt;p&gt;key:{item.name}&lt;/p&gt;
                  &lt;div&gt;
  
                      &lt;p&gt;add:{item.address}&lt;/p&gt;
                      &lt;p&gt;bank:{item.bank}&lt;/p&gt;
                      &lt;p&gt;bankaccount:{item.bankaccountnumber}&lt;/p&gt;
                      &lt;p&gt;baselocation:{item.baselocation}&lt;/p&gt;
                      &lt;p&gt;basicpay:{item.basicpay}&lt;/p&gt;
                      &lt;p&gt;branch:{item.branch}&lt;/p&gt;
                      &lt;p&gt;class:{item.class}&lt;/p&gt;
                      &lt;p&gt;confirmpassword:{item.confirmpassword}&lt;/p&gt;
                      &lt;p&gt;degree:{item.degree}&lt;/p&gt;
                      &lt;p&gt;designation:{item.designation}&lt;/p&gt;
                      &lt;p&gt;email:{item.email}&lt;/p&gt;
                      &lt;p&gt;mobilenumber:{item.mobilenumber}&lt;/p&gt;
                      &lt;p&gt;name:{item.name}&lt;/p&gt;
                      &lt;p&gt;password:{item.password}&lt;/p&gt;
                      &lt;p&gt;salary:{item.salary}&lt;/p&gt;
  
                  &lt;/div&gt;
              &lt;/div&gt;
          ))
      this.state.search = Test;
      return (
          &lt;div&gt;
  
  
              &lt;NativeSelect defaultValue="" name="name" onChange={this.handleChange}&gt;
                  &lt;option value="choose"&gt;choose&lt;/option&gt;
                  &lt;option value="Nabanit Koirala"&gt;Nabanit Koirala&lt;/option&gt;
                  &lt;option value="Saroj Kumar"&gt;Saroj Kumar&lt;/option&gt;
  
              &lt;/NativeSelect&gt;
              &lt;button type="submit" onClick={this.handleSubmit}&gt;Search&lt;/button&gt;
              &lt;div&gt;
                  {Test}
  
              &lt;/div&gt;
          &lt;/div&gt;
      )
  }
  }
  </code></pre>
  
  <p>Since i get the output value,the array stored in state is filtered and displayed in the browser,now i want to store the filtered array in state,so how can i do it now. </p>