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

Cannot omit auth provider on next branch #5201

Closed
jeiea opened this issue Aug 29, 2020 · 2 comments
Closed

Cannot omit auth provider on next branch #5201

jeiea opened this issue Aug 29, 2020 · 2 comments
Assignees
Labels

Comments

@jeiea
Copy link
Contributor

jeiea commented Aug 29, 2020

What you were expecting:
Minimal example should cause no error.

What happened instead:

`TypeError: Cannot read property 'getIdentity' of undefined.`
Uncaught TypeError: Cannot read property 'getIdentity' of undefined
    at useGetIdentity.js:81
    at commitHookEffectListMount (react-dom.development.js:19731)
    at commitPassiveHookEffects (react-dom.development.js:19769)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at flushPassiveEffectsImpl (react-dom.development.js:22853)
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushPassiveEffects (react-dom.development.js:22820)
    at performSyncWorkOnRoot (react-dom.development.js:21737)
    at react-dom.development.js:11089
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
    at flushSyncCallbackQueue (react-dom.development.js:11072)
    at unbatchedUpdates (react-dom.development.js:21909)
    at legacyRenderSubtreeIntoContainer (react-dom.development.js:24757)
    at Object.render (react-dom.development.js:24840)
    at Module../src/index.tsx (index.tsx:7)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object.1 (index.tsx:9)
    at __webpack_require__ (bootstrap:784)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.chunk.js:1

Steps to reproduce:

  1. Checkout react-admin next branch,
  2. Run make build
  3. Link example to next branch react-admin package.
  4. Run yarn start on example.

Related code:

Example code
import React from 'react';
import { Admin, Resource, List, Datagrid, TextField } from 'react-admin';

const PostList = props => (
  <List {...props}>
    <Datagrid>
      <TextField source="id" />
      <TextField source="title" />
      <TextField source="body" />
    </Datagrid>
  </List>
);

const data = [
  { id: 1, title: 'item 1', body: 'blah blah' },
  { id: 2, title: 'item 2', body: 'blah blah 2' },
  { id: 3, title: 'item 3', body: 'blah blah 3' },
];

const dataProvider = {
  getList: (resource, params) => Promise.resolve({ data, total: data.length }),
  getOne: (resource, params) => Promise.resolve({ data, total: data.length }),
  getMany: (resource, params) => Promise.resolve({ data, total: data.length }),
  getManyReference: (resource, params) =>
    Promise.resolve({ data, total: data.length }),
  create: (resource, params) => Promise.resolve({}),
  update: (resource, params) => Promise.resolve({}),
  updateMany: (resource, params) => Promise.resolve({}),
  delete: (resource, params) => Promise.resolve({}),
  deleteMany: (resource, params) => Promise.resolve({}),
};

export default () => (
  <Admin dataProvider={dataProvider}>
    <Resource name="posts" list={PostList} />
  </Admin>
);

Other information:

It seems useGetIdentity introduced recently.

const useGetIdentity = () => {
    const [state, setState] = useSafeSetState<State>({
        loading: true,
        loaded: false,
    });
    const authProvider = useAuthProvider();
    useEffect(() => {
        if (typeof authProvider.getIdentity === 'function') {
            const callAuthProvider = async () => {
                try {

I think auth provider check is missing here.

Environment

  • React-admin version: commit SHA d58084418
  • React version: latest stable (16.x)
  • Browser: Chrome
@djhi
Copy link
Collaborator

djhi commented Aug 31, 2020

Thanks for reporting.

@djhi
Copy link
Collaborator

djhi commented Sep 1, 2020

Fixed by #5209

@djhi djhi closed this as completed Sep 1, 2020
@djhi djhi added this to the 3.8.3 milestone Sep 1, 2020
@fzaninotto fzaninotto added bug and removed bug labels Sep 1, 2020
@fzaninotto fzaninotto removed this from the 3.8.3 milestone Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants