简体   繁体   中英

React & ASP.NET MVC 5 server side rendering console.log('text') does not show up

I have some code

index.cshtml

<div>
    @Html.React("App", new {i = 10})
</div>

App.jsx

class App extends React.Component{
    constructor(props){
       super(props);
       console.log(this.props.i);
    }

    render(){
        return (
            <div>this.props.i</div>
        )
    }
}

The console.log in the constructor doesn't print out in my terminal for some reason, but it shows the value 10 properly in the html. Any suggestions for fixing this or debugging React in asp.net? Thanks in advance.

class App extends React.Component{
    constructor(props){
       super(props);
       console.log(this.props.i);
    }

    render(){
        return (
            <div> { this.props.i } </div>
        )
    }
}

You should see the console on Server console

NOTE the typo on your render method. (missing {} )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM