markfinger / python-react

Server-side rendering of React components
MIT License
1.62k stars 116 forks source link

chrome dev tool debugger #79

Closed wx2228 closed 6 years ago

wx2228 commented 7 years ago

Firstly, I don't see the react component rendered on server side showing up in the Chrome dev tool react debugger, which is expected. But is there any way to achieve this?

Secondly I just started using this awesome library, it works perfect for static component. is this library gonna work if I have state in the component? and when the state changed, will the component changed too? or I have to send another request to render server for a new response?

markfinger commented 7 years ago

Firstly, I don't see the react component rendered on server side showing up in the Chrome dev tool react debugger, which is expected. But is there any way to achieve this?

Not that I'm aware of. The components render down to static markup, so the browser wont have any way to introspect the associated javascript.

Secondly I just started using this awesome library, it works perfect for static component. is this library gonna work if I have state in the component? and when the state changed, will the component changed too? or I have to send another request to render server for a new response?

You can use state within the components, but only the initial state that executes within the render server will be applied to the generated markup. Component state will not persist across renders, unless you send that state from the python process to the render server.

The usual workflow is to pre-render the components, then mount them on the client-side, so that you can provide interactivity to the user. To mount them client-side, you'll need to use something like webpack.