title: Adding a Table Row into a Table in React
body: <p>I am new to React and I am trying to build a very basic timesheet tool, where users can add tasks into the application and save. I am using React as well as Typescript.</p>
  
  <p>So far I have my main component that includes an empty array of tasks and the table. Then inside the table body I have mapped to pull the table rows and a separate component that includes the  tags.</p>
  
  <p>At the top of the table I have included a button that when clicked should create a new tasks array (so to not modify the state), then uses the concat method to the state to the new array of items and adds the new task. When the 'add item' button is clicked nothing happens, could someone tell me what I am doing wrong? and if this is the best way to achieve this?</p>
  
  <p>Main Component:</p>
  
  <pre><code>import * as React from 'react';
  import { ITimesheetToolProps } from './ITimesheetToolProps';
  import { escape } from '@microsoft/sp-lodash-subset';
  import TableRow from './TableRow';
  
  export default class TimesheetTool extends React.Component&lt;ITimesheetToolProps, any&gt; {
    state = {
      tasks: []
    }
  
    addTask = (task) =&gt; {
      const tasks = [...this.state.tasks];
      this.setState({tasks: this.state.tasks.concat(task)});
    }
  
    public render(): React.ReactElement&lt;ITimesheetToolProps, any&gt; {
      return (
        &lt;div&gt;
          &lt;button onClick={() =&gt; this.addTask}&gt;Add Task&lt;/button&gt;
          &lt;table&gt;
            &lt;thead&gt;
              &lt;th&gt;Project&lt;/th&gt;
              &lt;th&gt;Task&lt;/th&gt;
              &lt;th&gt;Monday&lt;/th&gt;
              &lt;th&gt;Tuesday&lt;/th&gt;
              &lt;th&gt;Wednesday&lt;/th&gt;
              &lt;th&gt;Thursday&lt;/th&gt;
              &lt;th&gt;Friday&lt;/th&gt;
              &lt;th&gt;Saaturday&lt;/th&gt;
              &lt;th&gt;Sunday&lt;/th&gt;
            &lt;/thead&gt;
            &lt;tbody&gt;
              {this.state.tasks.map(task =&gt; &lt;tr key={task}&gt;&lt;TableRow /&gt;&lt;/tr&gt;)}
            &lt;/tbody&gt;
          &lt;/table&gt;
        &lt;/div&gt;
      );
    }
  }
  </code></pre>
  
  <p>Table Row Component to be added onClick:</p>
  
  <pre><code>import * as React from 'react';
  import { ITimesheetToolProps } from './ITimesheetToolProps';
  
  export default class TableRow extends React.Component&lt;ITimesheetToolProps, {}&gt; {
      public render() {
          return (
             &lt;React.Fragment&gt;
                 &lt;td&gt;&lt;input type="text" name="project" /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type="text" name="task" /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type="number" name="mon" /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type="number" name="tues" /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type="number" name="wed" /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type="number" name="thurs" /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type="number" name="fri" /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type="number" name="sat" /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type="number" name="sun" /&gt;&lt;/td&gt;
             &lt;/React.Fragment&gt; 
          )
      }
  }
  </code></pre>