---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: useSolidForComponent
description: Learn more about useSolidForComponent
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="JavaScript (and super languages)" icon="seti:javascript">
## Summary
- Rule available since: `v2.0.0`
- Diagnostic Category: [`lint/performance/useSolidForComponent`](/reference/diagnostics#diagnostic-category)
- This rule isn't recommended, so you need to enable it.
- This rule doesn't have a fix.
- The default severity of this rule is [**information**](/reference/diagnostics#information).
- This rule belongs to the following domains:
  - [`solid`](/linter/domains#solid)
- Sources: 
  - Inspired from [`solid/prefer-for`](https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/prefer-for.md)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"performance": {
				"useSolidForComponent": "error"
			}
		}
	}
}

```
## Description
Enforce using Solid's `<For />` component for mapping an array to JSX elements.

In Solid, `<For />` component for efficiently rendering lists. Array#map causes DOM elements to be recreated.

For details on `<For />` Component, see the [Solid docs about Components](https://docs.solidjs.com/reference/components/for).

## Examples

### Invalid

```jsx
let Component = (props) => <ol>{props.data.map(d => <li>{d.text}</li>)}</ol>;
```

<pre class="language-text"><code class="language-text">code-block.jsx:1:33 <a href="https://biomejs.dev/linter/rules/use-solid-for-component">lint/performance/useSolidForComponent</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Array.prototype.map will cause DOM elements to be recreated, it is not recommended to use it in Solid here.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>let Component = (props) =&gt; &lt;ol&gt;&#123;props.data.map(d =&gt; &lt;li&gt;&#123;d.text&#125;&lt;/li&gt;)&#125;&lt;/ol&gt;;<br />   <strong>   │ </strong>                                <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Use Solid's </span><span style="color: lightgreen;"><strong>&lt;For /&gt;</strong></span><span style="color: lightgreen;"> component for efficiently rendering lists. See </span><span style="color: lightgreen;"><a href="https://docs.solidjs.com/reference/components/for">Solid docs</a></span><span style="color: lightgreen;"> for more details.</span><br />  <br /></code></pre>

```jsx
let Component = (props) => <>{props.data.map(d => <li>{d.text}</li>)}</>;
```

<pre class="language-text"><code class="language-text">code-block.jsx:1:31 <a href="https://biomejs.dev/linter/rules/use-solid-for-component">lint/performance/useSolidForComponent</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Array.prototype.map will cause DOM elements to be recreated, it is not recommended to use it in Solid here.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>let Component = (props) =&gt; &lt;&gt;&#123;props.data.map(d =&gt; &lt;li&gt;&#123;d.text&#125;&lt;/li&gt;)&#125;&lt;/&gt;;<br />   <strong>   │ </strong>                              <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Use Solid's </span><span style="color: lightgreen;"><strong>&lt;For /&gt;</strong></span><span style="color: lightgreen;"> component for efficiently rendering lists. See </span><span style="color: lightgreen;"><a href="https://docs.solidjs.com/reference/components/for">Solid docs</a></span><span style="color: lightgreen;"> for more details.</span><br />  <br /></code></pre>

```jsx
let Component = (props) => (
  <ol>
    {props.data.map((d) => (
      <li key={d.id}>{d.text}</li>
    ))}
  </ol>
);
```

<pre class="language-text"><code class="language-text">code-block.jsx:3:6 <a href="https://biomejs.dev/linter/rules/use-solid-for-component">lint/performance/useSolidForComponent</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Array.prototype.map will cause DOM elements to be recreated, it is not recommended to use it in Solid here.</span><br />  <br />    <strong>1 │ </strong>let Component = (props) =&gt; (<br />    <strong>2 │ </strong>  &lt;ol&gt;<br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>3 │ </strong>    &#123;props.data.map((d) =&gt; (<br />   <strong>   │ </strong>     <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>4 │ </strong>      &lt;li key=&#123;d.id&#125;&gt;&#123;d.text&#125;&lt;/li&gt;<br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>5 │ </strong>    ))&#125;<br />   <strong>   │ </strong>    <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>6 │ </strong>  &lt;/ol&gt;<br />    <strong>7 │ </strong>);<br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Use Solid's </span><span style="color: lightgreen;"><strong>&lt;For /&gt;</strong></span><span style="color: lightgreen;"> component for efficiently rendering lists. See </span><span style="color: lightgreen;"><a href="https://docs.solidjs.com/reference/components/for">Solid docs</a></span><span style="color: lightgreen;"> for more details.</span><br />  <br /></code></pre>

### Valid

```jsx
let Component = (props) => <ol><For each={props.data}>{d => <li>{d.text}</li>}</For></ol>;
```

```jsx
let abc = x.map(y => y + z);
```

```jsx
let Component = (props) => {
 let abc = x.map(y => y + z);
 return <div>Hello, world!</div>;
}
```

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/src/lint/performance/use_solid_for_component.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/tests/specs/performance/useSolidForComponent)

</TabItem>
</Tabs>