MCPcopy Create free account
hub / github.com/callstack/linaria / filterProps

Function filterProps

packages/react/src/styled.ts:58–82  ·  view source on GitHub ↗
(
  asIs: boolean,
  props: T,
  omitKeys: TKeys[]
)

Source from the content-addressed store, hash-verified

56};
57
58function filterProps<T extends Record<string, unknown>, TKeys extends keyof T>(
59 asIs: boolean,
60 props: T,
61 omitKeys: TKeys[]
62): Partial<Omit<T, TKeys>> {
63 const filteredProps = omit(props, omitKeys) as Partial<T>;
64
65 if (!asIs) {
66 /**
67 * A failsafe check for esModule import issues
68 * if validAttr !== 'function' then it is an object of { default: Fn }
69 */
70 const interopValidAttr =
71 typeof validAttr === 'function' ? { default: validAttr } : validAttr;
72
73 Object.keys(filteredProps).forEach((key) => {
74 if (!interopValidAttr.default(key)) {
75 // Don't pass through invalid attributes to HTML elements
76 delete filteredProps[key];
77 }
78 });
79 }
80
81 return filteredProps;
82}
83
84const warnIfInvalid = (value: unknown, componentName: string) => {
85 if (process.env.NODE_ENV !== 'production') {

Callers 1

renderFunction · 0.85

Calls 1

omitFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…