Do you use pure or impure functions in your React components? : <p>So i've been getting a little bit more into functional programming and immutability.</p>

<p>What I often do when writing a react component is a helper function that returns something based on props/state.</p>

<p>Currently I write both Pure and Impure functions even though most of them could be pure.</p>

<p>Examples for both cases:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>//pure function
const posts = this.props.posts;
const postId = this.props.selectedPostId;
const pureFunc = (postId, posts) =&gt; (posts.find(post =&gt; post.id === postId);

//impure function
const impureFunc = () =&gt; (
      this.props.posts.find(
          post =&gt; post.id === this.props.selectedPostId
      )
)</code></pre>
</div>
</div>
</p>

<p>Please, let's refrain from commenting on the overall structure and validity of the code.</p>

<p>The main point of comparison is to pass arguments and operate on those OR pass something from <code>this</code> context which is not like a global state, but it does feel a lot less like functional programming.</p>

<p>What do you prefer and think?</p>
