E
E
EA-EKB2021-10-05 16:04:47
React
EA-EKB, 2021-10-05 16:04:47

How to call different methods in two modules using a wrapper component over table (antd) when clicking on a table row?

Hello.

Please tell me how to make it so that when you click on a table row (a wrapper over table from antd) in each component (for example: the table of orders and the table of buyers) its own method is called? I read about the onRow parameter of the table, it seems to be what I need, but I'm not catching up ( Let's say I
use the openModal parameter to pass the function, I write in props in the wrapper component And here I get stuck with this id: number. Let's say this id is passed in the user table But in the table of orders, you need to pass the user id and, for example, the date of the order.To do this, props should be like this: Then the following follows in the text (again, only suitable for the users table):
openModal?: (id: number) => void,
openModal?: (id: number, date: string) => void,

const onRow = (record: { id: number }) => ({
    onClick: () => {
      if (openModal) {
        openModal(record.id);
      }
    },
  });

Please tell me how can this be done? More precisely, how to correctly pass a function with all its parameters using props? Google did not turn out anything similar (maybe the wrong request was made). This is probably a simple task, but this is my first time working with React and in general I don’t have much experience in JS.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question