Skip to content

Receiving backwardsDescriptor error #782

Open

Description

@Isaacmeedinaa

Hello, I am developing an e-commerce mobile application with React Native.

A Product can have many Categories and a Category can have many Products. Down below are my models:

Product.model.ts

import ModelNames from "./ModelNames.enum";
import { Model, attr, ModelType } from "redux-orm";

import ProductsActionTypes from "@actions/products/products.action-types";
import {
  ISetProductAction,
  IRemoveProductsAction,
} from "@actions/products/products.actions";

import IProduct from "@contracts/IProduct";

import { OrmSession } from "redux-orm/Session";
import { Schema } from "../orm";

interface ProductFields extends IProduct {}

type ProductAction = ISetProductAction | IRemoveProductsAction;

// Defines the Product class
class Product extends Model<typeof Product, ProductFields> {}

Product.modelName = ModelNames.PRODUCT;

Product.fields = {
  id: attr(),
  name: attr(),
  description: attr(),
  price: attr(),
  isActive: attr(),
  sequence: attr(),
  stockLevel: attr(),
  isUnlimited: attr(),
};

Product.reducer = (
  action: ProductAction,
  Product: ModelType<Product>,
  session: OrmSession<Schema>
) => {
  switch (action.type) {
    case ProductsActionTypes.SET_PRODUCT:
      // do something here
      return;
  }
};

export default Product;

Category.model.ts

import ModelNames from "./ModelNames.enum";
import { attr, Model, MutableQuerySet, many } from "redux-orm";
import ICategory from "@contracts/ICategory";
import Product from "./Product.model";

interface CategoryFields extends ICategory {
  productIds: MutableQuerySet<Product>;
}

class Category extends Model<typeof Category, CategoryFields> {}

Category.modelName = ModelNames.CATEGORY;

Category.fields = {
  id: attr(),
  name: attr(),
  sequence: attr(),
  productIds: many({
    to: "Product",
    as: "products",
    relatedName: "categories",
  }),
};

export default Category;

A screen shot of the error:
Simulator Screen Shot - iPhone 11 Pro Max - 2021-10-21 at 16 11 33

This only happens when I save my model file and React Native hot reloads the app.

Activity

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