<commit_before># Expr

`expr` can be used to create temporarily computed values inside computed values.
Nesting computed values is useful to create cheap computations to prevent expensive computations to run.

In the following example the expression prevents that the `TodoView` component is re-rendered if the selection changes elsewhere.
Instead the component will only re-render when the relevant todo is (de)selected.

```javascript
const TodoView = observer(({todo, editorState}) => {
    const isSelected = mobx.expr(() => editorState.selection === todo);
    return <div className={isSelected ? "todo todo-selected" : "todo"}>{todo.title}</div>;
});
```

`expr(func)` is an alias for `computed(func).get()`.<commit_msg>translate expr.md<100%><commit_after># Expr

`expr` 可以用来在计算值(computed values)中创建临时性的计算值。
嵌套计算值有助于创建低廉的计算以防止运行昂贵的计算。

在下面示例中，如果 selection 在其他地方改变，表达式会阻止 `TodoView` 组件重新渲染。
相反，只有当相关待办事项被(取消)选择时，组件才会重新渲染。

```javascript
const TodoView = observer(({todo, editorState}) => {
    const isSelected = mobx.expr(() => editorState.selection === todo);
    return <div className={isSelected ? "todo todo-selected" : "todo"}>{todo.title}</div>;
});
```

`expr(func)` 是 `computed(func).get()` 的别名。
{'fraction_non_alphanumeric': 0.1371900826446281, 'fraction_numerical': 0.0024793388429752068, 'mean_word_length': 5.84180790960452, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7352105', 'n_tokens_mistral': 448, 'n_tokens_neox': 461, 'n_words': 113}