measuredco / puck

The visual editor for React
https://puckeditor.com
MIT License
5.23k stars 310 forks source link

Prop name collisions #679

Open chrisvxd opened 1 day ago

chrisvxd commented 1 day ago

Via Discord

whenever you assign the same name of a specific prop for two different components, for example "content", but you give it different fields configurations, if you swap between selecting one of them to selecting another of them, you get the error "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." "The above error occurred in the component: at AutoFieldInternal"

For example if you do a config like this one:

config = {
  components: {
    ComponentA: {
      fields: {
        content: {
          type: "array",
          ...
        }
      },
      render: ({content}) => <ComponentA content={content}/>
    },
    ComponentB: {
      fields: {
        content: {
          type: "custom",
          ...
        }
      },
      render: ({content}) => <ComponentB content={content}/>
    }
  }
}

And you, in the editor, select a component a you have already dragged and drop, change something in the content, and then go to select a component b you already dragged and dropped, then this breakes the whole editor

chrisvxd commented 1 day ago

Struggling to reproduce. Requested reproduction repo via Discord.