Add React 18 support
React 18 replaces render with createRoot and root.render. (how to upgrade)
Is there a plan to update django-react-templatetags to support React 18?
Hi @matttk! Yes for sure, we just need to find the time to do some proper maintenance :)
For now, the best approach is to override the template https://github.com/Frojd/django-react-templatetags/blob/main/django_react_templatetags/templates/react_print.html
I'm renaming this issue and will have it on top of our todo list when we find the time.
for reference: i'm using this snippet right now (without hydration)
{% if components %}
{% for component in components %}
{{ component.json_obj|json_script:component.data_identifier }}
<script>
const container = document.getElementById('{{ component.identifier }}');
const root = ReactDOMClient.createRoot(container);
root.render(
React.createElement({{ component.name }}, JSON.parse(document.getElementById("{{ component.data_identifier }}").textContent)),
);
</script>
{% endfor %}
{% endif %}
with these imports
import React from "react";
import ReactDOMClient from "react-dom/client";
como se integra django-react-templateta a react 18?