![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@solid-primitives/keyed
Advanced tools
Control Flow primitives and components that require specifying explicit keys to identify or rerender elements.
Control Flow primitives and components that require specifying explicit keys to identify or rerender elements.
keyArray
- Reactively maps an array by specified key with a callback function - underlying helper for the <Key>
control flow.Key
- Creates a list of elements by mapping items by provided key.Entries
- Creates a list of elements by mapping object entries.Rerun
- Causes the children to rerender when the on
changes.npm install @solid-primitives/keyed
# or
yarn add @solid-primitives/keyed
keyArray
Reactively maps an array by specified key with a callback function - underlying helper for the <Key>
control flow.
import { keyArray } from "@solid-primitives/keyed";
The keyArray
primitive takes 4 arguments:
list
- input list of values to mapkeyFn
- key getter, items will be identified by it's value. changing the value is changing the item.mapFn
- reactive function used to create mapped output item. Similar to Array.prototype.map
but both item and index are signals, that could change over time.options
- a fallback for when the input list is empty or missing (Optional)const mapped = keyArray(source, (model, index) => {
const [name, setName] = createSignal(model().name);
const [description, setDescription] = createSignal(model().description);
createComputed(() => {
setName(model().name);
setDescription(model().description);
});
return {
id: model.id,
get name() {
return name();
},
get description() {
return description();
},
get index() {
return index();
},
setName,
setDescription,
};
});
Notice that both the value and index arguments are singlas. Items are identified only by keys, it means that the items could be copied, replaced, changed, but as long as the key is the same, keyArray
will treat it as the same item.
<Key>
Creates a list of elements by mapping items by provided key. Similar to Solid's <For>
and <Index>
, but here, both value and index arguments are signals.
But changing the value does not rerender the element, only where the value is being used.
import { Key } from "@solid-primitives/keyed";
Both each
and by
have to be provided. The fallback
prop is optional, it will be displayed when the list in each
is missing or empty.
<Key each={items()} by={item => item.id} fallback={<div>No items</div>}>
{item => <div>{item()}</div>}
</Key>
prop by
can also be an object key
<Key each={items()} by="id">
Second argument of the map function is an index signal.
<Key each={items()} by="id">
{(item, index) => <div data-index={index()}>{item()}</div>}
</Key>
https://codesandbox.io/s/solid-primitives-keyed-key-demo-gh7gd?file=/index.tsx
<Entries>
Creates a list of elements by mapping object entries. Similar to Solid's <For>
and <Index>
, but here, render function takes three arguments, and both value and index arguments are signals.
import { Entries } from "@solid-primitives/keyed";
<Entries of={object()} fallback={<div>No items</div>}>
{(key, value) => (
<div>
{key}: {value()}
</div>
)}
</Entries>;
Third argument of the map function is an index signal.
<Entries of={object()} fallback={<div>No items</div>}>
{(key, value, index) => (
<div data-index={index()}>
{key}: {value()}
</div>
)}
</Entries>
<Rerun>
Causes the children to rerender when the on
key changes. Equivalent of v-key
in vue, and {#key}
in svelte.
Note: Since Solid 1.5.0 the
<Show>
component has akeyed
prop that works very similarly to<Rerun>
.
import { Rerun } from "@solid-primitives/keyed";
You have to provide a on
prop. Changing it, will cause the children to rerender.
const [count, setCount] = createSignal(0);
// will rerender whole <button>, instead of just text
<Rerun on={count()}>
<button onClick={() => setCount(p => ++p)}>{count()}</button>
</Rerun>;
// or pass a function
<Rerun on={() => count()}/>
// or an array of dependencies
<Rerun on={[count, name, length]}/>
You can treat on
prop like sources argument of the Solid's on
helper, and the children as the second, callback argument.
<Rerun on={[count, className]}>
{([count, className]) => (
<button class={className} onClick={() => setCount(p => ++p)}>
{count}
</button>
)}
</Rerun>
<Rerun>
can be used together with solid-transition-group
to animate single component's transition, on state change.
<Transition name="your-animation" mode="outin">
<Rerun on={count()}>
<button onClick={() => setCount(p => ++p)}>{count()}</button>
</Rerun>
</Transition>
https://codesandbox.io/s/solid-primitives-keyed-rerun-demo-14vjr?file=/index.tsx
See CHANGELOG.md
FAQs
Control Flow primitives and components that require specifying explicit keys to identify or rerender elements.
The npm package @solid-primitives/keyed receives a total of 0 weekly downloads. As such, @solid-primitives/keyed popularity was classified as not popular.
We found that @solid-primitives/keyed demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.