title: Blazor Reusable RenderFragments in code with event : Cannot convert lambda expression to intended delegate type
body: <p>Anyone knows why the below doesn't work? If I remove &quot;onclick&quot; event then it compiles &amp; works as expected. Is that we are not allowed to use event within <a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/webassembly-performance-best-practices?view=aspnetcore-3.1#define-reusable-renderfragments-in-code" rel="nofollow noreferrer">Reusable RenderFragments</a>?</p>
  <p>Env: ASP.NET Core 3.1 &amp; Blazor Web Assembly</p>
  <p>Thanks a lot for the help in advance!</p>
  <p><strong>Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type</strong></p>
  <p><a href="https://i.stack.imgur.com/qfFT1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qfFT1.png" alt="enter image description here" /></a></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@code {
      RenderFragment&lt;(CategoryDto category, int myId)&gt; rf =
        val =&gt; __builder =&gt;
        {
          &lt;h1 @onclick="()=&gt; Console.WriteLine(val.category.Name)"&gt;Hello @val.category.Name, @val.myId&lt;/h1&gt;
        };
  }</code></pre>
  </div>
  </div>
  </p>