Skip to content
Advertisement

Tag: spread

Pass properties but make exceptions in React

There is something common that sometimes we all do. Wrap dom elements in custom components <CustomComponet id=”abc” title=”abc” nonDomProp=”abc” …andsoforth /> Custom component in this example wraps button which has the properties id and title but not nonDomProp so I get a warning which makes sense because nonDomProp doesn’t exist in the wrapped button DOM element and I am just

Spread Operator – TypeScript

I’m trying to pass an array as an argument with Spread operator but something is going wrong. Answer For TypeScript to correctly predict what argument types are going to spread into the parameter, you will have to change the args variable type into a tuple as follows:

Advertisement