Skip to content

ReactDOM is not defined #480

@optimatex

Description

@optimatex

I looked through all similar issues in this repo, but my case is really strange. I reduce my code as much as possible but this error is still there
My current bundle file (I use webpack)

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import ReactDOMServer from 'react-dom/server';

global.React = React;
global.ReactDOM = ReactDOM;
global.ReactDOMServer = ReactDOMServer;
global.__SERVER__ = true;

require('expose?Post!./post');
require('expose?React!react');
require('expose?ReactDOM!react-dom');

and here is my simple component

class Post extends Component {
   render() {
      return <div>Post title</div>;
   }
}

module.exports = Post;

and finally in .cshtml file

<div id="appRoot">
        @Html.React("Post", new
    {
        Title = @Model.Title
    })        
    </div>
    @Html.ReactInitJavaScript();

that's all. But I still get those error. What can cause it? When I remove @Html.React error stop appears

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions