Skip to content

Commit

Permalink
feat: throw when inputContainer refers to an <input> (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahdayan committed Jul 23, 2020
1 parent 09e09bf commit da536fc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/SearchButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import { getDomElement } from '../utils';
export const SearchButton = ({ onClick }) => {
const { config } = useAppContext();

const inputContainer = getDomElement(config.inputContainer);

if (inputContainer instanceof HTMLInputElement) {
throw new Error(
'The `inputContainer` option must refer to a container (e.g., <div>), not an <input>.'
);
}

return ReactDOM.createPortal(
<button
type="button"
Expand All @@ -28,7 +36,7 @@ export const SearchButton = ({ onClick }) => {
</kbd>
)}
</button>,
getDomElement(config.inputContainer)
inputContainer
);
};

Expand Down

0 comments on commit da536fc

Please sign in to comment.