Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomField issue : Line 19:37: 'props' is not defined no-undef #6363

Closed
neps-in opened this issue Jun 16, 2021 · 5 comments · Fixed by #6365
Closed

CustomField issue : Line 19:37: 'props' is not defined no-undef #6363

neps-in opened this issue Jun 16, 2021 · 5 comments · Fixed by #6365

Comments

@neps-in
Copy link
Contributor

neps-in commented Jun 16, 2021

What you were expecting:

Custom Field Not working Line 19:37: 'props' is not defined no-undef
What happened instead:

I am using the exact same code as below https://marmelab.com/react-admin/Fields.html

import * as React from "react";
import { List, Datagrid, TextField, useRecordContext } from 'react-admin';

const FullNameField = () => {
    const record = useRecordContext(props);

    return <span>{record.firstName} {record.lastName}</span>;
}

FullNameField.defaultProps = { label: 'Name' };

export const UserList = (props) => (
    <List {...props}>
        <Datagrid>
            <FullNameField source="lastName" />
        </Datagrid>
    </List>
);

Steps to reproduce:

Related code:

import * as React from "react";
import { List, Datagrid, TextField, useRecordContext } from 'react-admin';

const FullNameField = () => {
    const record = useRecordContext(props);

    return <span>{record.firstName} {record.lastName}</span>;
}

FullNameField.defaultProps = { label: 'Name' };

export const UserList = (props) => (
    <List {...props}>
        <Datagrid>
            <FullNameField source="lastName" />
        </Datagrid>
    </List>
);
insert short code snippets here

Other information:

Environment

  • React-admin version: latest
  • Last version that did not exhibit the issue (if applicable):
  • React version: latest
  • Browser: chrome
  • Stack trace (in case of a JS error): Line 19:37: 'props' is not defined no-undef
@neps-in
Copy link
Contributor Author

neps-in commented Jun 16, 2021

In the example following the line The component will be: pass the props like this

const FullNameField = (props) => {
    const record = useRecordContext(props);

    return <span>{record.firstName} {record.lastName}</span>;
}

Very obvious though, if you can add to the doc that would be great.

Btw, fantastic library react-admin, Coooooooool

@djhi
Copy link
Contributor

djhi commented Jun 16, 2021

Thanks for reporting this and the kind words. Would you mind opening a PR?

@neps-in
Copy link
Contributor Author

neps-in commented Jun 16, 2021

PR ?

@neps-in
Copy link
Contributor Author

neps-in commented Jun 16, 2021

pull request ? on the doc ?

@djhi
Copy link
Contributor

djhi commented Jun 16, 2021

Yes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants