node.js - ComponentDidMount() in Server-side render -
i'm trying server-side render webpage better performance running issue page's components componentdidmount()
s aren't getting called.
for example, main template file:
import react 'react'; import cube './components/cube/cube.jsx'; class index extends react.component { render() { return ( <html> <head> <title>{this.props.title}</title> </head> <body> <cube /> </body> </html> ); } }
and cube.jsx:
import react 'react'; class cube extends react.component { componentdidmount() { console.log("hey!"); } render() { return ( <div> <h1>hello</h1> </div> ); } } export default cube;
i'm not seeing "hey!" getting logged out in pm2 logs nor in chrome console though i'm seeing <h1>hello</h1>
when page loads. stopping me having sort of logic component.
how around problem , make subcomponents's componentdidmount()
called? note i'm using express-react-views
server-side rendering.
i think lifecycle hook called server side componentwillmount
explained here
even not see output on chrome's console. see in node logs.
let me know if answers question.
Comments
Post a Comment