Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create circular relationships between blocks #8738

Closed
eudago opened this issue Oct 16, 2024 · 0 comments
Closed

Create circular relationships between blocks #8738

eudago opened this issue Oct 16, 2024 · 0 comments
Labels

Comments

@eudago
Copy link

eudago commented Oct 16, 2024

Describe the Bug

I want to create a block (named BlockA) that can be used to wrap other blocks (BlockB), and the BlockB can have the BlockA as a child.

But I'm facing a circular dependency issue, the error is

Error: Cannot access 'BlockA' before initialization

I expect to resolve this by using dynamic imports to avoid the circular dependency issue, like this.

....
BlockB
....
content: [
    {
        type: "blocks",
        name: "blocks",
        required: false,
        blocks: async () => {
            const { BlockA } = await import("../example/blockA.block");
            return [
                BlockA,
            ];
        },
    },
],

However, blocks don't accept a promise. How can I resolve this? Is it possible to use blocks recursively?

Link to the code that reproduces this issue

.

Reproduction Steps

Create a two blocks with circular relationships between each other

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Payload: 3.0.0-beta.28
Nextjs: 14.3.0-canary.21

@eudago eudago added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Oct 16, 2024
@payloadcms payloadcms locked and limited conversation to collaborators Oct 16, 2024
@r1tsuu r1tsuu converted this issue into discussion #8741 Oct 16, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Oct 16, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

1 participant