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

151
Views
Reactjs use component attributes/props in another component

i have three components. one draws a circle, one draws a line and one is their container. in container, i use props to give coordination for circles. i want to use that coordination (two cx and two cy ) in my other component to draw a line between them. is there a way that i can pass id of my points to my line component and use their x and y values (like get attribute in Javascript)? here is my code for better understanding

point component

import React from 'react';

const Point = ({ p_cx, p_cy, id }) => {
  return (
    <>
      <circle cx={`${p_cx}`} cy={`${p_cy}`} r={5} fill='white' id={`${id}`} />
    </>
  );
};

export default Point;

line component

import React from 'react';

const Line = ({ L_x1, L_y1, L_x2, L_y2, id1 }) => {
  return (
    <>
      <path
        d={
          'M' + `${L_x1}` + ' ' + `${L_y1}` + 'L' + `${L_x2}` + ' ' + `${L_y2}`
        }
        stroke='green'
        fill='red'
        strokeWidth={5}
        id={`${id1}`}
      />
    </>
  );
};

export default Line;

container

import React from 'react';
import Line from './line';
import Point from './points';

const Pointsdraw = () => {
  return (
    <svg>
      <g>
        <Point p_cx={20} p_cy={50} id={'abcd'} />
        <Point p_cx={10} p_cy={60} id={'aaa'} />
      </g>
      <g>
        <Line />
      </g>
    </svg>
  );
};

export default Pointsdraw;
about 4 years ago · Santiago Trujillo
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!