Simple! Just override the template react_print.html
This library only covers the template parts (that is: placeholder and js render).
Sure! Just add the param identifier="yourid"
in react_render
.
Example:
{% react_render component="Component" identifier="yourid" %}
...will print
<div id="yourid"></div>
Add your props as arguments prefixed with prop_*
to your {% react_render ... %}
.
Example:
{% react_render component="Component" prop_country="Sweden" prop_city="Stockholm" %}
...will give the component this payload:
React.createElement(Component, {"country": "Sweden", "city": "Stockholm"}),
Add class="yourclassname"
to your {% react_render ... %}
.
Example:
{% react_render component="Component" class="yourclassname" %}
...will print
<div id="Component_405190d92bbc4d00b9e3376522982728" class="yourclassname"></div>
Yup, just pass the header HTTP_X_DISABLE_SSR
in your request and SSR will be skipped in that response.
Yes! Just remove the string declaration and reference a variable in your {% react_render ... %}
, the same way you do with props
.
Example:
This view
render(request, 'myapp/index.html', {
'component_name': 'MegaMenu',
})
...and this template
{% react_render component=component_name %}
...will print:
<div id="Component_405190d92bbc4d00b9e3376522982728" class="yourclassname"></div>
React.createElement(MegaMenu),