`Element` is not defined during server-side rendering
See original GitHub issueHello!
I get this error with version 4.0.0-rc.1.
…/node_modules/react-bootstrap-typeahead/lib/core/Overlay.js:46 referenceElement: _propTypes[“default”].instanceOf(Element) ^
ReferenceError: Element is not defined at Object.<anonymous> (…/node_modules/react-bootstrap-typeahead/lib/core/Overlay.js:46:54) at Module._compile (internal/modules/cjs/loader.js:738:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:749:10) at Module.load (internal/modules/cjs/loader.js:630:32) at tryModuleLoad (internal/modules/cjs/loader.js:570:12) at Function.Module._load (internal/modules/cjs/loader.js:562:3) at Module.require (internal/modules/cjs/loader.js:667:17) at require (internal/modules/cjs/helpers.js:20:18) at Object.<anonymous> (…/node_modules/react-bootstrap-typeahead/lib/components/Typeahead.react.js:26:39) at Module._compile (internal/modules/cjs/loader.js:738:30)
My implementation looks like this: …
public render(): JSX.Element {
const options = [
{ id: 0, firstName: 'Jon0', lastName: 'Doe0' },
{ id: 1, firstName: 'Jon1', lastName: 'Doe1' },
{ id: 2, firstName: 'Jon2', lastName: 'Doe2' },
{ id: 3, firstName: 'Jon3', lastName: 'Doe3' },
];
return <AsyncTypeahead
isLoading={this.state.isLoading}
labelKey={option => `${option.firstName} ${option.lastName}`}
onSearch={(query) => {
this.setState({ isLoading: true });
if (this.hTimeout) {
clearTimeout(this.hTimeout);
}
this.hTimeout = setTimeout(() => {
this.setState({
isLoading: false,
options,
});
}, 3000);
}}
options={this.state.options}
/>
}
…
Anyone else gets this? I am using react-bootstrap 1.0.0-beta.16 and @types/react-bootstrap-typeahead 3.4.5. Can that be it?
Cheers!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Thanks again for the report @Phrensoua. This should be fixed in v4.0.0-rc.2
PropTypes.element
&PropTypes.elementType
actually aren’t appropriate here. I think something more generic likePropTypes.object
is probably the way to go.Edit: Looks like shimming
Element
might be the way to go: