diff --git a/packages/react-native-ui-lib/src/commons/asBaseComponent.tsx b/packages/react-native-ui-lib/src/commons/asBaseComponent.tsx index 26c1704a89..bcdb696f42 100644 --- a/packages/react-native-ui-lib/src/commons/asBaseComponent.tsx +++ b/packages/react-native-ui-lib/src/commons/asBaseComponent.tsx @@ -55,7 +55,7 @@ function asBaseComponent(WrappedCompone }; static getDerivedStateFromError(error: any) { - UIComponent.defaultProps?.onError?.(error, WrappedComponent.defaultProps); + UIComponent.defaultProps?.onError?.(error); return {error: true}; } @@ -80,6 +80,7 @@ function asBaseComponent(WrappedCompone hoistStatics(BaseComponent, WrappedComponent); BaseComponent.displayName = WrappedComponent.displayName; BaseComponent.propTypes = WrappedComponent.propTypes; + // @ts-expect-error class component have defaultProps and functions do not and so should not be affected by this BaseComponent.defaultProps = WrappedComponent.defaultProps; const ThemeContext = ThemeManager.getThemeContext(); if (ThemeContext) { diff --git a/packages/react-native-ui-lib/src/commons/forwardRef.tsx b/packages/react-native-ui-lib/src/commons/forwardRef.tsx index 38b08d8bfa..526b7469c8 100644 --- a/packages/react-native-ui-lib/src/commons/forwardRef.tsx +++ b/packages/react-native-ui-lib/src/commons/forwardRef.tsx @@ -17,10 +17,7 @@ export default function forwardRef(WrappedC const ForwardedComponent = React.forwardRef(forwardRef); hoistStatics(ForwardedComponent, WrappedComponent); - //@ts-ignore ForwardedComponent.displayName = WrappedComponent.displayName; - //@ts-ignore - ForwardedComponent.defaultProps = WrappedComponent.defaultProps; return ForwardedComponent as typeof ForwardedComponent & STATICS; } diff --git a/packages/react-native-ui-lib/src/commons/withScrollEnabler.tsx b/packages/react-native-ui-lib/src/commons/withScrollEnabler.tsx index 2bdc77ebdc..8cd4e34fbb 100644 --- a/packages/react-native-ui-lib/src/commons/withScrollEnabler.tsx +++ b/packages/react-native-ui-lib/src/commons/withScrollEnabler.tsx @@ -69,8 +69,6 @@ function withScrollEnabler(WrappedComponent: React.Componen hoistStatics(ScrollEnabler, WrappedComponent); ScrollEnabler.displayName = WrappedComponent.displayName; - //@ts-ignore - ScrollEnabler.defaultProps = WrappedComponent.defaultProps; return forwardRef(ScrollEnabler) as any; } diff --git a/packages/react-native-ui-lib/src/commons/withScrollReached.tsx b/packages/react-native-ui-lib/src/commons/withScrollReached.tsx index ea1da67579..56fde6f8ef 100644 --- a/packages/react-native-ui-lib/src/commons/withScrollReached.tsx +++ b/packages/react-native-ui-lib/src/commons/withScrollReached.tsx @@ -92,8 +92,6 @@ function withScrollReached(WrappedComponent: React.Componen hoistStatics(ScrollReachedDetector, WrappedComponent); ScrollReachedDetector.displayName = WrappedComponent.displayName; - //@ts-ignore - ScrollReachedDetector.defaultProps = WrappedComponent.defaultProps; return forwardRef(ScrollReachedDetector) as any; } diff --git a/packages/react-native-ui-lib/src/components/icon/index.tsx b/packages/react-native-ui-lib/src/components/icon/index.tsx index f012f8e32b..4eb7bcd0f5 100644 --- a/packages/react-native-ui-lib/src/components/icon/index.tsx +++ b/packages/react-native-ui-lib/src/components/icon/index.tsx @@ -129,9 +129,6 @@ const Icon = forwardRef((props: Props, ref: any) => { }); Icon.displayName = 'Icon'; -Icon.defaultProps = { - assetGroup: 'icons' -}; export default asBaseComponent>(Icon, {modifiersOptions: {margins: true}}); diff --git a/packages/react-native-ui-lib/src/helpers/DocsGenerator.js b/packages/react-native-ui-lib/src/helpers/DocsGenerator.js deleted file mode 100644 index f3e5429768..0000000000 --- a/packages/react-native-ui-lib/src/helpers/DocsGenerator.js +++ /dev/null @@ -1,61 +0,0 @@ -import React from 'react'; -import _ from 'lodash'; - -const TAB = ' '; -const LINE_BREAK = '\n'; - -export function extractComponentInfo(instance) { - const componentName = instance.constructor.displayName; - const defaultProps = instance.constructor.defaultProps || {}; - const props = instance.props || {}; - return {componentName, defaultProps, props}; -} - -export function generateSnippet({componentName, defaultProps, props}) { - let snippet = `<${componentName}`; - - _.forEach(props, (value, key) => { - if (key === 'children') { - return; - } - let formattedValue = `{${value}}`; - if (_.isObject(value)) { - formattedValue = `{${JSON.stringify(value)}}`; - } else if (_.isString(value)) { - formattedValue = `"${value}"`; - } else if (_.isBoolean(value) && value === true) { - formattedValue = ''; - } - - const hasEmptyValue = _.isUndefined(value) || (_.isObject(value) && _.isEmpty(value)); - const hasDefaultValue = value == defaultProps[key]; // eslint-disable-line - if (!hasEmptyValue && !hasDefaultValue) { - snippet += `${LINE_BREAK}${TAB}${key}`; - if (formattedValue) { - snippet += `=${formattedValue}`; - } - } - }); - - if (props.children) { - const childrenSnippets = React.Children.map(props.children, child => { - if (_.get(child, 'type.displayName')) { - const childSnippet = - TAB + - generateSnippet({ - componentName: child.type.displayName, - props: child.props || {}, - defaultProps: child.type.defaultProps || {} - }); - return childSnippet; - } - if (typeof child === 'string') { - return child; - } - }); - snippet += `>${LINE_BREAK}${childrenSnippets.join(LINE_BREAK)}${LINE_BREAK}`; - } else { - snippet += '/>'; - } - return snippet; -}