revert pure components used with observer

This commit is contained in:
Oprysk 2021-12-14 12:04:57 +02:00
parent 5f618c2979
commit 63d2732f60
3 changed files with 4 additions and 6 deletions

View File

@ -29,7 +29,7 @@ export interface FieldProps extends SchemaOptions {
} }
@observer @observer
export class Field extends React.PureComponent<FieldProps> { export class Field extends React.Component<FieldProps> {
toggle = () => { toggle = () => {
if (this.props.field.expanded === undefined && this.props.expandByDefault) { if (this.props.field.expanded === undefined && this.props.expandByDefault) {
this.props.field.expanded = false; this.props.field.expanded = false;

View File

@ -18,7 +18,7 @@ export interface ObjectSchemaProps extends SchemaProps {
}; };
} }
export const ObjectSchemaComponent = observer( export const ObjectSchema = observer(
({ ({
schema: { fields = [], title }, schema: { fields = [], title },
showTitle, showTitle,
@ -78,5 +78,3 @@ export const ObjectSchemaComponent = observer(
); );
}, },
); );
export const ObjectSchema = React.memo<ObjectSchemaProps>(ObjectSchemaComponent);

View File

@ -7,7 +7,7 @@ import * as React from 'react';
import { filterPropsDeep } from '../../utils/test-utils'; import { filterPropsDeep } from '../../utils/test-utils';
import { ObjectSchemaComponent, ObjectSchema, Schema } from '../'; import { ObjectSchema, Schema } from '../';
import { OpenAPIParser, SchemaModel } from '../../services'; import { OpenAPIParser, SchemaModel } from '../../services';
import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions';
import * as simpleDiscriminatorFixture from './fixtures/simple-discriminator.json'; import * as simpleDiscriminatorFixture from './fixtures/simple-discriminator.json';
@ -26,7 +26,7 @@ describe('Components', () => {
options, options,
); );
const schemaViewElement = shallow(<Schema schema={schema} />).getElement(); const schemaViewElement = shallow(<Schema schema={schema} />).getElement();
expect(schemaViewElement.type).toEqual(ObjectSchemaComponent); expect(schemaViewElement.type).toEqual(ObjectSchema);
expect(schemaViewElement.props.discriminator).toBeDefined(); expect(schemaViewElement.props.discriminator).toBeDefined();
expect(schemaViewElement.props.discriminator.parentSchema).toBeDefined(); expect(schemaViewElement.props.discriminator.parentSchema).toBeDefined();
expect(schemaViewElement.props.discriminator.fieldName).toEqual('type'); expect(schemaViewElement.props.discriminator.fieldName).toEqual('type');