Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
React hook get triggered on closing sidebar of streamlit when using React D3 component( https://github.com/andfanilo/streamlit-d3-demo)

i am using useEffect hook to re-render graph when data is changed as shown below

const svgRef = useRef(null)
const { svgWidth, svgHeight, data, line_data, key }: PythonArgs = props.args

useEffect(() => {
       Chart()
       .container(svgRef.current)
       .data(data)
       .render()
   }, [])


   // Hook to update data
   useEffect(() => {
       Chart()
           .container(svgRef.current)
           .data(data)
           .render()
   },[data])

but whenever i click on close button the hook gets triggered.

Attached is the screenshot of sidebar.

Thanks

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Remove the first hook. Modify the second as following:

useEffect(() => {
  if (data && svgRef.current) {
    Chart().container(svgRef.current).data(data).render();
  }
},[data, svgRef]);

Does it help?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!