1

I'm facing an issue in react-admins ra-data-json-server.

import jsonServerProvider from 'ra-data-json-server';

const dataProvider = jsonServerProvider('https://jsonplaceholder.typicode.com');

export default function App() {
    return (
        <Admin dataProvider={dataProvider}>
            <Resource
                name="posts"
                list={ListGuesser}
                show={ShowGuesser}
                edit={EditGuesser}
            />
        </Admin>
    );
}

getting the console error:

Error: Unknown dataProvider function: toJSON
    at Proxy.eval (useDataProvider.ts:96:31)
    at JSON.stringify (<anonymous>)
    at Object.parseData (<anonymous>:8:116)
    at <anonymous>:10:2186
    at Array.reduce (<anonymous>)
    at <anonymous>:10:2114
    at i (<anonymous>:10:2706)
    at <anonymous>:10:2993
    at _ (<anonymous>:10:3119)
    at <anonymous>:10:3363

The application is running, the data that is fetched looks correct, but i can not get rid of the console error of the react_devtools_backend.

I created a minimal react-admin app using the jsonplaceholder api on stackblitz.io. Even there the console error is showing up every time.

Url to the minimal app where you can see the console error if you have react-dev-tools installed: https://react-ts-rj6rfi.stackblitz.io/#/posts

Used packages:

  • react-admin: 4.5.2
  • ra-data-json-server: 4.5.2
  • react: 18.2.0
  • react-dom: 18.2.0

1 Answers1

0

If you're using the JSONPlaceholder API, why don't you use ra-data-json-server instead of ra-data-simple-rest? The former is designed for that API language.

As for your error, the latest react-admin codebase doesn't have a single toSJON call. So the error must come from another package in your installation. And your error message doesn't help because the trace only shows <anonympus>...

François Zaninotto
  • 7,068
  • 2
  • 35
  • 56
  • Thank you for your answer. Ich edited my initial post, because it was eventually missleading. In my current project i am using the `ra-data-simple-rest` because it is communicatiing witha an REST-API. The minimal Project i created on stackblitz.io is using the `ra-data-json-server`, but the error is still showing up. – Zicheng Wang Nov 21 '22 at 12:36
  • Maybe it is an issue within react-dev-tools and has nothing to do with `react-admin` nor the `dataProvider`? – Zicheng Wang Nov 21 '22 at 12:55
  • I am not getting any error with your Stackblitz on Chrome. Try upgrading/disabling your extensions? – François Zaninotto Nov 22 '22 at 19:35
  • I uninstalled the Extension `react-context-devTool`. Only using `React-Developer-Tools` and the console error is gone. – Zicheng Wang Nov 23 '22 at 06:40
  • Great! Then please mark your question as solved, this helps a lot for future searches. – François Zaninotto Nov 30 '22 at 17:52