I am using Draft.js and need to recurse into props.children
to find components of type DraftEditorBlock
.
For some reason, this doesn't really seem to work:
import React from 'react';
import { DraftEditorBlock } from 'draft-js';
...
export default class MyBlockRenderer extends React.Component {
...
render() {
const { children } = this.props;
const firstChild = React.Children.toArray(children)[0];
if (firstChild instanceof DraftEditorBlock) {
...
}
...
}
}
The line where instanceof
is used causes this error:
TypeError: Right-hand side of 'instanceof' is not an object
What am I doing wrong?