Skip to content

Uncaught TypeError: Cannot read property session of undefined #744

Open

Description

@vdhand-xactly

I am using redux-orm for a react project. But, I can't figure out this error:

useSelector.js:38 Uncaught TypeError: Cannot read property 'session' of undefined
    at memoize.js:189
    at index.jsx:68
    at useSelectorWithStoreAndSubscription (useSelector.js:29)
    at useSelector2 (useSelector.js:106)
    at App (index.jsx:68)
    at renderWithHooks (react-dom.development.js:14985)
    at mountIndeterminateComponent (react-dom.development.js:17811)
    at beginWork (react-dom.development.js:19049)
    at HTMLUnknownElement.callCallback2 (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)

index.jsx:68
const formDefinitions = useSelector(state => fullFormDefinitionSelector(state)); // ! This is causing an error

formDefinitionSelectors.js

// Selector to return fully populated datasources.
export const fullFormDefinitionSelector = createSelector(
    orm,
    session => {
        return session.FormDefinition.all()
            .toModelArray()
            .map(fd => {
                return {
                    ...fd.ref,
                    schema: fd.schema.toRefArray(),
                };
            });
    },

From, some debugging, I got to know that this issue is coming inside the memoize function. Apparently, the memize function is being called two times on initial render. The first time it is called, it has 3 arguments. But, when it is called for the second time, I just has one argument. So, the form argument is undefined inside the memoize function. This gives me the error: 'session' of undefined.
image

Activity

  1. Isaacmeedinaa commented on Oct 21, 2021

    @Isaacmeedinaa

    Hello, any fix?

  2. vdhand-xactly commented on Oct 21, 2021

    @vdhand-xactly
    Author

    Unfortunately, this library is not maintained anymore 😞

  3. Isaacmeedinaa commented on Oct 21, 2021

    @Isaacmeedinaa

    @vdhand-xactly Are you sure, how can we verify this? It makes sense because it's very buggy specially with Typescript. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions