paypal / react-engine

a composite render engine for universal (isomorphic) express apps to render both plain react views and react-router views
Apache License 2.0
1.45k stars 130 forks source link

Unable to pass function during react-router rendering #198

Closed zer0Id0l closed 6 years ago

zer0Id0l commented 6 years ago

I was trying to pass a function as payload parameter during react router rendering, but seems like all function type fields in render payload object are stripped out. Any particular reason for that reason?

res.render(${requestURI}${req.url}, { fn: fn, pageData: data })

My guess is that, we would usually render a page with static content hence only basic fields which are allowed to render initial state are allowed.

jonathansamines commented 6 years ago

@zer0Id0l I think the reason is more likely to be related that the render "context" you provide is passed through JSON.stringify as you can see here. The reason, is because that properties are "rendered" to a plain html page later, so it would'nt make sense to pass down functions anyway.