linaria
linaria copied to clipboard
Provide an option to disable props filtering
Describe the enhancement
Provide an option to disable props filtering.
Motivation
Now, there is a filter for props:
https://github.com/callstack/linaria/blob/master/packages/react/src/styled.ts#L111-L120
But the conditions for checking whether an element is HTML tag or custom element are not satisfy with our cases.
We have some element with names like: View
、Text
、Input
from WeChat MiniApp,and both of them have some special attributes like: hoverClass
.Once linaria filter these attributes, then it will not work correctly.
Possible implementations
// Check if it's an HTML tag and not a custom element
if (options.enablePropsFilter && typeof component === 'string' && component.indexOf('-') === -1) {
// ...
} else {
filteredProps = rest;
}
Hi @Chen-jj!
Unfortunately, there is no clear way to pass such an option to styled
. However, there are no built-in components that start with a capital letter, so will it be enough for you if I add a check that will ignore all components that start with a capital?
Fixed in #970
@Anber Thanks for fixing it.However, we use styled('view')
in that case, because it refers to a built-in component with React.createElement
.According to your PR, we can use styled('View')
, but could you please change to lowercase for us before passing to React.createElement
?Otherwise, React will refers to a user-defined component and throw an error.
@Chen-jj Unfortunately, it seems like there is no way to detect whether or not passed argument is a default tag or a custom component. According to the specs, names of custom components must have a hyphen, so View
and especially view
are just wrong names and we cannot support them.
Ok, I have an idea, but I need some time to implement it.