Skip to content

Commit

Permalink
Merge pull request #8983 from marmelab/AutocompleteArrayInput-stories…
Browse files Browse the repository at this point in the history
…-CustomOption

Fix `<AutocompleteArrayInput>` 'custom options' story
  • Loading branch information
fzaninotto authored Jun 7, 2023
2 parents e09bca3 + ddf6c40 commit 2e4c31b
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import * as React from 'react';
import { Admin } from 'react-admin';
import { RaRecord, Resource, required, useCreate } from 'ra-core';
import {
RaRecord,
Resource,
required,
useCreate,
useRecordContext,
} from 'ra-core';
import polyglotI18nProvider from 'ra-i18n-polyglot';
import englishMessages from 'ra-language-english';
import { createMemoryHistory } from 'history';
Expand Down Expand Up @@ -226,11 +232,14 @@ export const CustomTextFunction = () => (
</Admin>
);

const CustomOption = ({ record, ...rest }: { record?: RaRecord }) => (
<div {...rest}>
{record?.fullName}&nbsp;<i>({record?.language})</i>
</div>
);
const CustomOption = () => {
const record = useRecordContext();
return (
<div>
{record?.fullName}&nbsp;<i>({record?.language})</i>
</div>
);
};

const BookEditCustomOptions = () => {
const choices = [
Expand Down

0 comments on commit 2e4c31b

Please sign in to comment.