Skip to content

Commit

Permalink
fix: drop warning when render is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahdayan committed May 9, 2022
1 parent bd33132 commit 2f9c2d2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
10 changes: 1 addition & 9 deletions packages/autocomplete-js/src/__tests__/renderer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ describe('renderer', () => {
);
});

test('warns about new `renderer.render` option when specifying an incomplete renderer and a `render` option', () => {
test('does not warn at all when specifying an incomplete renderer and a `render` option', () => {
const container = document.createElement('div');
const panelContainer = document.createElement('div');
const mockCreateElement = jest.fn().mockImplementation(preactCreateElement);
Expand Down Expand Up @@ -426,14 +426,6 @@ describe('renderer', () => {
});
}

expect(startAutocomplete).toWarnDev(
'[Autocomplete] You provided the `render` option but did not provide a `renderer.render`. Since v1.6.0, you can provide a `render` function directly in `renderer`.' +
'\nTo get rid of this warning, do any of the following depending on your use case.' +
"\n- If you are using the `render` option only to override Autocomplete's default `render` function, pass the `render` function into `renderer` and remove the `render` option." +
'\n- If you are using the `render` option to customize the layout, pass your `render` function into `renderer` and use it from the provided parameters of the `render` option.' +
'\nSee https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-render'
);

expect(startAutocomplete).not.toWarnDev(
'[Autocomplete] You provided an incomplete `renderer` (missing: `renderer.Fragment`, `renderer.render`). This can cause rendering issues.' +
'\nSee https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-renderer'
Expand Down
9 changes: 0 additions & 9 deletions packages/autocomplete-js/src/getDefaultOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ export function getDefaultOptions<TItem extends BaseItem>(
'The `container` option does not support `input` elements. You need to change the container to a `div`.'
);

warn(
!(render && renderer && !renderer?.render),
`You provided the \`render\` option but did not provide a \`renderer.render\`. Since v1.6.0, you can provide a \`render\` function directly in \`renderer\`.` +
`\nTo get rid of this warning, do any of the following depending on your use case.` +
"\n- If you are using the `render` option only to override Autocomplete's default `render` function, pass the `render` function into `renderer` and remove the `render` option." +
'\n- If you are using the `render` option to customize the layout, pass your `render` function into `renderer` and use it from the provided parameters of the `render` option.' +
'\nSee https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-render'
);

warn(
!renderer ||
render ||
Expand Down

0 comments on commit 2f9c2d2

Please sign in to comment.