BuilderIO / BuilderIO/builder

Custom components with list props do not update immediately in qwik

Open
#3,735 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.8k
Forks
1.2k
Avg merge
1d 6h
Merged PRs (30d)
17

Description

**Describe the bug**
Custom components with fields of type `list` do not _always_ re-render when props change.

**To Reproduce**
Steps to reproduce the behavior:
1. Create custom component with list type
2. Render list
3. Change props (title in this example)

**Expected behavior**
Expect both renders of the list to update as the props change.

**Screenshots**
Screenshot 2024-11-15 at 14 00 40

**Additional context**
It seems that adding optional chaining when using the list props for some reason works, even though the props are initialised with a default value so technically the contents of the field list shouldn't ever be undefined. Or alternatively I would expect to see an error when accessing the title or items props. I have observed this only for list type fields.

```
// component config
export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
{
component: CustomList,
name: "CustomList",
inputs: [
{
name: 'items',
type: 'list',
defaultValue: [
{
title: 'Item one',
},
],
subFields: [
{
name: 'title',
type: 'string',
defaultValue: 'Item title',
required: true,
},
],
required: true,
},
],
},
];

// CustomList component
export default component$((props) => {
return (


This works


{props.items.map((item, key) => (
  • {item?.title}

  • ))}

    This doesn't work


    {props.items.map((item, key) => (
  • {item.title}

  • ))}

    );
    });
    ```

    Contributor guide

    No contributing guide indexed for this repository

    Assessment

    This issue has not been assessed yet.

    Get new issues in your inbox

    A short digest of beginner-friendly GitHub issues.