Today, to register child components, we must do something like this:
this.registerChild(childComponent);
The template of the parent component might then look something like this:
<div>
<h1>Hello world!</h1>
<child-component-name></child-component-name>
</div>
The trouble is that child-component-name is defined inside the JS file for the child component -- the tagName. It creates a hard dependency between the two classes. It is possible for the parent component to overwrite that component name by passing in the tagName to the child component constructor -- but that's cumbersome and not very convenient. In practice, the parent component just ends up using whatever the child component defined as their tagName.
If the child component gets refactored at a later date and gets a new tagName, then it would break any other component that uses it.
As a possible solution I think we should remove tagName from the Nimbly component configs and allow components to specify the name of a child component when it's being registered.
So the registerChild method would become something like this:
this.registerChild(childComponent, "component-name");
This will get a bit more complicated for registering child components for repeatable sections, will need to discuss with the team.
Today, to register child components, we must do something like this:
The template of the parent component might then look something like this:
The trouble is that
child-component-nameis defined inside the JS file for the child component -- thetagName. It creates a hard dependency between the two classes. It is possible for the parent component to overwrite that component name by passing in thetagNameto the child component constructor -- but that's cumbersome and not very convenient. In practice, the parent component just ends up using whatever the child component defined as theirtagName.If the child component gets refactored at a later date and gets a new
tagName, then it would break any other component that uses it.As a possible solution I think we should remove
tagNamefrom the Nimbly component configs and allow components to specify the name of a child component when it's being registered.So the
registerChildmethod would become something like this:this.registerChild(childComponent, "component-name");This will get a bit more complicated for registering child components for repeatable sections, will need to discuss with the team.