N
N
Ninja Mate2016-04-03 20:07:38
React
Ninja Mate, 2016-04-03 20:07:38

How to set up require.ensure?

require.ensure([], function(require) { require('./Facility'); }, 'Facility');

what am I doing wrong?
the module itself is connected (I see it in the sources), but it gives errors and is not rendered

Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `NonPatientSer`
Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `NonPatientSer`.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Ninja Mate, 2016-04-04
@victorzadorozhnyy

did this and it works, but when reloading the page, it gives an error accessing
and the files are already on the server, .... but it works

componentDidMount(){
        var Facility;
        require.ensure([], function(require) {
            Facility = require('./Facility').default;
            render(<Facility/>, document.getElementById('fl'));
        }, 'facility');
    }
    render() {

        return (
            <div>
                <div id="fl"></div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question