Issue #3500Opened May 28, 2021by vijayshukla300 reactions

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)

artfJune 1, 20210 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.