Skip to content

Commit

Permalink
fix: replace defaultProps with default parameters in SpreadsheetImport (
Browse files Browse the repository at this point in the history
twentyhq#7406)

This PR addresses twentyhq#6827

React has deprecated the use of `defaultProps` on function components
and will remove support in a future major release. This commit replaces
the usage of `defaultProps` in the `SpreadsheetImport` component with
default parameters to fix the following warning:

**Changes:**

- Removed `SpreadsheetImport.defaultProps =
defaultSpreadsheetImportProps;`
- Merged `defaultSpreadsheetImportProps` with incoming `props` using
object spread syntax.
- Adjusted the component to use the merged props (`mergedProps`) instead
of `props`.
  • Loading branch information
gazjones00 authored and harshit078 committed Oct 14, 2024
1 parent 6d7812b commit fce10ac
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ export const defaultSpreadsheetImportProps: Partial<
export const SpreadsheetImport = <T extends string>(
props: SpreadsheetImportProps<T>,
) => {
const mergedProps = {
...defaultSpreadsheetImportProps,
...props,
} as SpreadsheetImportProps<T>;

return (
<ReactSpreadsheetImportContextProvider values={props}>
<ModalWrapper isOpen={props.isOpen} onClose={props.onClose}>
<ReactSpreadsheetImportContextProvider values={mergedProps}>
<ModalWrapper isOpen={mergedProps.isOpen} onClose={mergedProps.onClose}>
<SpreadsheetImportStepperContainer />
</ModalWrapper>
</ReactSpreadsheetImportContextProvider>
);
};

SpreadsheetImport.defaultProps = defaultSpreadsheetImportProps;

0 comments on commit fce10ac

Please sign in to comment.