Re-render React component from Laravel blade

I am using React component inside of Laravel blade, I am using the following attributes

<div class="card" data-controller="react" data-react-widget-type="Data" data-react-props="someData"></div>

It works fine except when I change the DOM element after an event and add new props, then the React component will not be rendered again and the new props will not be used in the component.

The scenario in short is, I am uploading a file using jQuery, depending on its response, I am updating the DOM element of react widget, then I need to re-render the component.

1 answer

  • answered 2021-02-23 12:02 Nikolai Kiselev

    You can upload a file and change the state of the React component instead of its properties. Otherwise you need to write your own listener, that watches for changes in document's element and triggers re-render (which is inefficient).