ZebbraCredo.Check.AssignInRender (zebbra_credo v1.0.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of high and works with any version of Elixir.

Explanation

An assign made in a LiveView's or LiveComponent's render/1 counts as changed on every render, so every patch re-renders whatever reads it: a whole table, if its rows do. Compute the value where its inputs change (mount, handle_params, handle_event, update) or read it in the template:

hidden_columns={Map.get(@collection_hidden_columns, @collection_id, [])}

Function components assign as usual; this check reads only render/1.

Check-Specific Parameters

Use the following parameters to configure this check:

:app

The app's root module; its web module is where use <Web>, :live_view is recognised.

This parameter defaults to nil.

:web

The app's web namespace when it is not <app>Web.

This parameter defaults to nil.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.