Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: remove strict mode wrapper and react version check #43

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .storybook/decorators/withTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import '@gravity-ui/uikit/styles/styles.scss';
import './styles.scss';

export const withTheme: DecoratorFn = (Story, context) => (
<React.StrictMode>
<ThemeProvider theme={context.globals.theme}>
<Story {...context} />
</ThemeProvider>
</React.StrictMode>
<ThemeProvider theme={context.globals.theme}>
<Story {...context} />
</ThemeProvider>
);
6 changes: 1 addition & 5 deletions src/lib/core/components/Form/hooks/useField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import _ from 'lodash';

import {isArraySpec, isNumberSpec, isObjectSpec, isReact18OrMore} from '../../../helpers';
import {isArraySpec, isNumberSpec, isObjectSpec} from '../../../helpers';
import {Spec} from '../../../types';
import {OBJECT_ARRAY_CNT, OBJECT_ARRAY_FLAG, REMOVED_ITEM} from '../constants';
import {
Expand Down Expand Up @@ -255,10 +255,6 @@ export const useField = <Value extends FieldValue, SpecType extends Spec>({
firstRenderRef.current = false;

return () => {
if (isReact18OrMore()) {
firstRenderRef.current = true;
}

(parentOnUnmount ? parentOnUnmount : tools.onUnmount)(name);
};
}, []);
Expand Down
7 changes: 0 additions & 7 deletions src/lib/core/components/Form/hooks/useStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import _ from 'lodash';
import {useForm} from 'react-final-form';

import {isReact18OrMore} from '../../../helpers';
import {DynamicFieldStore, FieldObjectValue, FieldValue, ValidateError} from '../types';
import {transformArrIn} from '../utils';

Expand Down Expand Up @@ -65,12 +64,6 @@ export const useStore = (name: string) => {

React.useEffect(() => {
firstRenderRef.current = false;

return () => {
if (isReact18OrMore()) {
firstRenderRef.current = true;
}
};
}, []);

return {tools, store};
Expand Down
4 changes: 0 additions & 4 deletions src/lib/core/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import _ from 'lodash';

import {SpecTypes} from './constants';
Expand Down Expand Up @@ -29,5 +27,3 @@ export const isObjectSpec = (candidate: any): candidate is ObjectSpec =>

export const isStringSpec = (candidate: any): candidate is StringSpec =>
candidate?.type === SpecTypes.String;

export const isReact18OrMore = () => Number(React.version.split('.')[0]) >= 18;