How could I move towards a react front end?

What I love about dash is that it allows me to use a python server to pipe data into, process and send plots to my front end. With DMC and caching we can get pretty good load times and performance on top of that. Being able to write layout in python and have it work is also great.

What I fear dash is not so great with, is that every small tweak to a component needs to be fully built as a dash component. DMC covers most use cases but there’s many things I would like to do directly in react (or other front end) that would require so many awkward callbacks that change layout. There are also times that I want to update components based on third party API’s or databases that have no need to get any python processing.

What I’m getting to is that it would be great to be able to also start writing front end code in react and then connect it to my server side callback in my flask app when say I want to load a chart.

I guess dash already basically does this, but internally. It must somehow connect those callbacks using the request payload to the _dash-update-component endpoint.

How can I write react that updates some components from a python/flask/dash server? Or could dash be tweaked to allow this?

Hello @lex1,

There are two options here:

1- with the release of dash 2.16.1, there was the addition of dash_clientside.set_props. This allows for any component/js to directly impact a dash component without the need to perform strange workaround.

2 - you can create a namespace in your application for all your other components to exist in. Your react components should allow for setProps and loading_state to be passed to it. Then on Python side you could create a basic wrapper for your components to convert into an object that dash will render. All dash needs is a namespace, component and then the props you want to pass it.

Oh cool, thanks for those ideas!

Too late for me to understand fully, and I think I might need a little demo or snippet to help me visualise more if you can

Number2 sounds like building dash components or am I wrong?

Sounds like both are pretty close though :slight_smile:

2 - yes and no.

It can be a little more streamlined potentially.