Remove custom trait by its type.
Question
I have created a custom trait but the name of that trait will be dynamic which is unknown. The problem is that the current removeTrait() only works with name/id. But what if I want to remove all traits from the component with custom-trait.
Ex: I create a trait 'my-custom-trait' and bind it to the component. component.addTrait({ name: 'some_random', options:[], type: 'my-custom-trait' });
Now, I want to remove it but I don't know the name.
Answers (1)
You can use of the ID
component.addTrait({
id: 'my-custom-trait',
name: 'some_random',
// ...
});
// ...
component.removeTrait('my-custom-trait')
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2170
[QUESTION] Custom component - how to set editable to true
Hi, I've created a custom component type, but I am having some trouble making it editable. The component is a "span" with component type "t...
Issue #2007
[QUESTION] Adding new traits to component and update current ones with these
I have some custom components created before modifying their traits (for example, I created a new trait for it), these components wont cont...
Issue #2226
[QUESTION] Updating a component type trait definition after init
I have created a custom component & block which is used to display/embed uploaded files. I have defined traits for this component see below...
Issue #3409
[QUESTION] Custom component property that is not a trait
I would like to create a custom component with a property that will be updated by specific code, but I don't want this property to be visib...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.