I'm trying to create an RN Object with a constructor passing json object but I'm getting "ReferenceError: Can't find variable: Product".
Product.js
export default class Product {
constructor(product) {
this.name = product.name
this.items = product.Items
this.price = product.Price
this.productID = product.ProductID
this.medias = product.Medias
this.imageSmall = BASE_IMAGES_URL + product.MediaSmall
this.imageLarge = this.getImageLarge(product.Medias)
}
}
PDP.js
import { Product } from '../models/Product'
class PDP extends Component {
render() {
var imagesProd = [];
var product = new Product(this.props.navigation.state.params.currentProduct);
....
}
}
the problem is with new Product()
using directly this.props.navigation.state.params.currentProduct
works fine.
EDIT
After your tips, I changed the import to import Product from '../models/Product'
but I'm getting
TypeError: TypeError: TypeError: TypeError: undefined is not a constructor (evaluating 'new P.default(s)')