dkapur17 / streamlit-flow

Streamlit Component to quickly create Interactive Flow Diagrams using React Flow
https://stflow.streamlit.app
52 stars 6 forks source link

Modify flow without re-rendering #10

Open hspeace opened 3 days ago

hspeace commented 3 days ago

This project is just what I need in terms of process creation! Currently, I re-render the flow by deleting the key of the flow. I would like to ask how to modify the flow information through code without re-rendering, such as creating nodes/modifying node names.

dkapur17 commented 3 days ago

Hey @hspeace. Unfortunately, because of the way Streamlit works, assigning a key to the component ensures that component is not remounted when its arguments change. The problem is that state management is impossible without a key, so each flow component needs to have a key. As such the a work around is to delete the key and cause the component to re-render, as done in the Hackable State demo.

It is possible that there is a cleaner work around than this, but I haven't been able to find one yet.

hspeace commented 2 days ago

@dkapur17 I see. I'm struggling with this too. I would like to know if you have implemented the relevant context-aware menu yourself, and whether can also implement drag and drop generation so that users can better create nodes through drag and drop. Please refer to https://reactflow.dev/examples/interaction/drag-and-drop. grateful!

dkapur17 commented 2 days ago

Yes, the context menus in this library have been made specifically for this library and are not offered by Reactflow. I'll look into implementing drag-and-drop in the next version. Thanks for the feedback.