A
A
Anton-Mumbli2020-07-31 16:34:45
React
Anton-Mumbli, 2020-07-31 16:34:45

How to pass record values ​​to a custom component in react-admin?

Good day. Please tell me how to solve the problem.
I am using react-admin.
There is RequestEdit.jsx
Edit component, SimpleForm and TextField components react-admin.
AboutProject is custom mine.

const RequestEdit = props => {
    const classes = useEditStyles();
    return (
        <div>
            <AboutProject/>
            <Edit
                title={<RequestTitle />}
                classes={classes}
                {...props}
            >
                <SimpleForm>
                    <TextField source="name" />
                    <TextField source="username" />
                </SimpleForm>
            </Edit>
        </div>
    );
};

It is passed to title RequestTitle
const RequestTitle = ({ record }) => {
    return <h2>{record ? `${record.name}` : ''}</h2>;
};

If I pass react-admin to native components, then everything is displayed normally, but I don’t know how to correctly transfer the same entries to custom components.
How can I pass a record to a custom component, like AboutProject, so that I can use the same record.name there?

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