refactor: convert function expressions to declarations (#4926)
This commit is contained in:
committed by
GitHub
parent
c0236536dd
commit
141a2eba56
@ -8,9 +8,11 @@ import { reactSelectStyles } from 'netlify-cms-ui-default';
|
||||
import { stringTemplate } from 'netlify-cms-lib-widgets';
|
||||
import { FixedSizeList } from 'react-window';
|
||||
|
||||
const Option = ({ index, style, data }) => <div style={style}>{data.options[index]}</div>;
|
||||
function Option({ index, style, data }) {
|
||||
return <div style={style}>{data.options[index]}</div>;
|
||||
}
|
||||
|
||||
const MenuList = props => {
|
||||
function MenuList(props) {
|
||||
if (props.isLoading || props.options.length <= 0 || !Array.isArray(props.children)) {
|
||||
return props.children;
|
||||
}
|
||||
@ -28,7 +30,7 @@ const MenuList = props => {
|
||||
{Option}
|
||||
</FixedSizeList>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function optionToString(option) {
|
||||
return option && option.value ? option.value : '';
|
||||
|
@ -2,7 +2,9 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { WidgetPreviewContainer } from 'netlify-cms-ui-default';
|
||||
|
||||
const RelationPreview = ({ value }) => <WidgetPreviewContainer>{value}</WidgetPreviewContainer>;
|
||||
function RelationPreview({ value }) {
|
||||
return <WidgetPreviewContainer>{value}</WidgetPreviewContainer>;
|
||||
}
|
||||
|
||||
RelationPreview.propTypes = {
|
||||
value: PropTypes.node,
|
||||
|
@ -4,7 +4,10 @@ import { render, fireEvent, waitFor } from '@testing-library/react';
|
||||
import { NetlifyCmsWidgetRelation } from '../';
|
||||
|
||||
jest.mock('react-window', () => {
|
||||
const FixedSizeList = props => props.itemData.options;
|
||||
function FixedSizeList(props) {
|
||||
return props.itemData.options;
|
||||
}
|
||||
|
||||
return {
|
||||
FixedSizeList,
|
||||
};
|
||||
@ -45,7 +48,7 @@ const nestedFieldConfig = {
|
||||
value_field: 'title',
|
||||
};
|
||||
|
||||
const generateHits = length => {
|
||||
function generateHits(length) {
|
||||
const hits = Array.from({ length }, (val, idx) => {
|
||||
const title = `Post # ${idx + 1}`;
|
||||
const slug = `post-number-${idx + 1}`;
|
||||
@ -89,7 +92,7 @@ const generateHits = length => {
|
||||
data: { title: 'JSON post', slug: 'post-json', body: 'Body json' },
|
||||
},
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
const simpleFileCollectionHits = [{ data: { categories: ['category 1', 'category 2'] } }];
|
||||
|
||||
|
@ -2,13 +2,15 @@ import controlComponent from './RelationControl';
|
||||
import previewComponent from './RelationPreview';
|
||||
import schema from './schema';
|
||||
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'relation',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
schema,
|
||||
...opts,
|
||||
});
|
||||
function Widget(opts = {}) {
|
||||
return {
|
||||
name: 'relation',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
schema,
|
||||
...opts,
|
||||
};
|
||||
}
|
||||
|
||||
export const NetlifyCmsWidgetRelation = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetRelation;
|
||||
|
Reference in New Issue
Block a user