How to use the ra-core.useDataProvider function in ra-core

To help you get started, we’ve selected a few ra-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marmelab / react-admin / packages / ra-ui-materialui / src / button / BulkExportButton.tsx View on Github external
const BulkExportButton: FunctionComponent = ({
    resource,
    selectedIds,
    onClick,
    label = 'ra.action.export',
    icon = defaultIcon,
    ...rest
}) => {
    const exporter = useContext(ExporterContext);
    const dataProvider = useDataProvider();
    const notify = useNotify();
    const handleClick = useCallback(
        event => {
            exporter &&
                dataProvider
                    .getMany(resource, { ids: selectedIds })
                    .then(({ data }) =>
                        exporter(
                            data,
                            fetchRelatedRecords(dataProvider),
                            dataProvider,
                            resource
                        )
                    )
                    .catch(error => {
                        console.error(error);
github marmelab / react-admin / packages / ra-ui-materialui / src / button / ExportButton.tsx View on Github external
const ExportButton: FunctionComponent = ({
    exporter,
    sort,
    filter = defaultFilter,
    maxResults = 1000,
    resource,
    onClick,
    label = 'ra.action.export',
    icon = DefaultIcon,
    ...rest
}) => {
    const dataProvider = useDataProvider();
    const notify = useNotify();
    const handleClick = useCallback(
        event => {
            dataProvider
                .getList(resource, {
                    sort,
                    filter,
                    pagination: { page: 1, perPage: maxResults },
                })
                .then(({ data }) =>
                    exporter
                        ? exporter(
                              data,
                              fetchRelatedRecords(dataProvider),
                              dataProvider
                          )
github go-zepto / zepto / plugins / linkeradmin / frontend / packages / linkeradmin / src / core / generator / fields / compGens / ReferenceList / index.tsx View on Github external
const ReferenceListDatagrid = (props: ReferenceListDatagridProps) => {
  const recordID = props.recordID;
  const redirect = useRedirect();
  const [rows, setRows] = useState([]);
  const dp = useDataProvider();
  useEffect(() => {
    const filter: any = {};
    filter[`${props.refResourceFieldName}_eq`] = recordID;
    dp.getList(props.resource.endpoint, {
      filter,
      pagination: {
        page: 1,
        perPage: 10,
      },
      sort: {
        field: 'id',
        order: "ASC",
      }
    }).then(res => {
      setRows(res?.data || []);
    })