Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Creating a block definition to replace previous block causes error

default discord avatar
notchr2 years ago
10

"index.js:179 Uncaught TypeError: Cannot destructure property 'blockType' of 'row' as it is undefined."



@364124941832159242

Sorry for ping, but I'm worried I broke something...is it possible my payload install is behind?



This is on the admin side, adding a Block to a collection



The page goes blank and prints that error



I'm on

"payload": "^1.3.0"


import { Block, CollectionConfig } from "payload/types";

const BannerBlock: Block = {
  slug: "Banner",
  fields: [
    {
      name: "section",
      type: "text",
      required: true,
    },
    {
      name: "title",
      label: "Image Banner Title",
      type: "text",
      required: true,
    },
    {
      name: "subtitle",
      label: "Image Banner Sub-Title",
      type: "text",
      required: true,
    },
    {
      name: "image",
      type: "upload",
      relationTo: "media",
      required: true,
    },
  ],
};

const PanelBlock: Block = {
  slug: "Panels",
  fields: [
    {
      name: "section",
      type: "text",
      required: true,
    },
    {
      name: "panels", // required
      type: "array", // required
      label: "Content Panels",
      minRows: 1,
      maxRows: 4,
      labels: {
        singular: "Panel",
        plural: "Panels",
      },
      fields: [
        {
          name: "title",
          type: "text",
          required: true,
        },
        {
          name: "content",
          type: "textarea",
        },
        {
          name: "link",
          type: "text",
        },
        {
          name: "icon",
          type: "text",
        },
      ],
    },
  ],
};

const Pages: CollectionConfig = {
  slug: "pages",
  access: {
    read: () => true,
  },
  admin: {
    useAsTitle: "title",
  },
  fields: [
    {
      name: "title",
      label: "Page Title",
      type: "text",
      required: true,
      unique: true,
    },
    {
      name: "description",
      label: "Page Description",
      type: "textarea",
      required: true,
    },
    {
      name: "layout", // required
      type: "blocks", // required
      minRows: 1,
      maxRows: 20,
      blocks: [BannerBlock, PanelBlock],
    },
  ],
};

export default Pages;
  • discord user avatar
    jmikrut
    2 years ago

    what is the Payload version that you actually have installed?



    i would also try and use these exact field configs in a brand-new and empty Payload project created with

    npx create-payload-app

    , to see if the problem persists



    this seems like a data problem, maybe you have docs that are out of date or similar. but if you can create this issue with a new / blank project, using these exact field / block definitions, then it would appear to be a bug and we can help look at this immediately

  • default discord avatar
    notchr2 years ago
    @364124941832159242

    Thanks my friend!



    @364124941832159242

    Sadly updating did not fix the issue :/



    I had a block before, "SliderBlock"



    I renamed it, changed its schema a bit



    To BannerBlock



    updated the collection config



    But now I can add blocks to the collection



    cant*

  • discord user avatar
    jmikrut
    2 years ago

    ahhh ok, if you renamed it, you should write a migration script to go through all your old docs, find any instances of the old block slug, and update them to the new block slug

  • default discord avatar
    notchr2 years ago

    I'm not sure how to do that



    I figured it would take care of that kind of thing for me :X

  • discord user avatar
    jmikrut
    2 years ago

    i believe there are some examples in our GitHub discussions about quick migration scripts



    but yeah, migrations are manual as with most every ORM. We don't change your existing data ever for you, at least not yet

  • default discord avatar
    notchr2 years ago

    With prisma i can just do like prisma migrate dev --name



    it would be nice to do prisma migrate



    err payload migrate



    and have it do that kind of thing

  • discord user avatar
    jmikrut
    2 years ago

    that could very well be a thing that we build in the future

  • default discord avatar
    notchr2 years ago

    when i get financially stable enough ill quit my job and join payload



    😛

  • discord user avatar
    jmikrut
    2 years ago

    well, the good news there is that we will be prioritizing hiring future engineers straight from our community 😈

  • default discord avatar
    notchr2 years ago

    hehe amazing



    My speciality is more like webgl / 3d stuff



    But I do enjoy this kind of dev



    TBH, I was looking at some other headless cms systems last night



    And it's really rough out there



    Payload is the only one who's marketing doesnt automatically make me feel like they just want all my $$$$$



    And ive tried like, 7 of them



    That and it works nicely



    I mean not that you guys dont wnat $ but



    you care about the community



    etc



    anyway, ill let you get back to it



    TY 😄

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.