title: Wrong components rendered by Preact
body: <p>I'm using Preact (for all intents and purposes, React) to render a list of items, saved in a state array. Each item has a remove button next to it. My problem is: when the button is clicked, the proper item is removed (I verified this several time), but the items are re-rendered with the <strong>last</strong> item missing, and the removed one still there. My code (simplified):</p>
  
  <pre><code>import { h, Component } from 'preact';
  import Package from './package';
  
  export default class Packages extends Component {
    constructor(props) {
      super(props);
      let packages = [
        'a',
        'b',
        'c',
        'd',
        'e'
      ];
      this.setState({packages: packages});
    }
  
    render () {
      let packages = this.state.packages.map((tracking, i) =&gt; {
        return (
          &lt;div className="package" key={i}&gt;
            &lt;button onClick={this.removePackage.bind(this, tracking)}&gt;X&lt;/button&gt;
            &lt;Package tracking={tracking} /&gt;
          &lt;/div&gt;
        );
      });
      return(
        &lt;div&gt;
          &lt;div className="title"&gt;Packages&lt;/div&gt;
          &lt;div className="packages"&gt;{packages}&lt;/div&gt;
        &lt;/div&gt;
      );
    }
  
    removePackage(tracking) {
      this.setState({packages: this.state.packages.filter(e =&gt; e !== tracking)});
    }
  }
  </code></pre>
  
  <p>What am I doing wrong? Do I need to actively re-render somehow? Is this an n+1 case somehow?</p>
  
  <p><strong>Clarification</strong>: My problem is not with the synchronicity of state. In the list above, if I elect to remove 'c', the state is updated correctly to <code>['a','b','d','e']</code>, but the components rendered are <code>['a','b','c','d']</code>. At every call to <code>removePackage</code> the correct one is removed from the array, the proper state is shown, but a wrong list is rendered. (I removed the <code>console.log</code> statements, so it won't seem like they are my problem).</p>