jpuri / react-draft-wysiwyg

A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg
MIT License
6.42k stars 1.16k forks source link

err in typescript #521

Open printjs opened 7 years ago

printjs commented 7 years ago

error

Uncaught Error: Objects are not valid as a React child (found: object with keys {Editor}). If you meant to render a collection of children, use an array instead.

code:

import * as React from 'react';
const Editor = require('react-draft-wysiwyg');

const styles = require('./editor.scss');

export class PlaceholderTextEditor extends React.Component<any, {}> {
    constructor(props: any) {
        super(props);
    }

    componentDidMount() {
    }

    render() {
        return (
            <section className='placeholder-text-editor-panel'>
                <Editor />
            </section>
        );
    }
}

without 'react-draft-wysiwyg' is normal.

environment

jpuri commented 7 years ago

Hey @wjtGitHub , the trouble here is with import. Editor is not default export of the lib. Thus its not a valid react component.

printjs commented 6 years ago

@jpuri ,thank you. but, how to import react-draft-wysiwyg under typescript