GsranjifyQuickzLook.js
import React, { Component } from 'react';
import { connect } from 'react-redux';
import loopSkus from './stranify';
class GsranjifyQuickzLook extends Component {
componentDidMount() {
loopSkus(this.props.data)
}
}
const mapStateToProps = state => {
const data = get(state, 'navigation.breadcrumbs');
return { data };
};
export default connect(mapStateToProps)(GsranjifyQuickzLook);
stranify.js
export const loopSkus = (productDataForSk) => {
return productDataForSku.skus.map(sku => `{
"id": "${get(sku, 'id')}",
"title": "${get(productDataForSku, 'name')}",
"brand": "${get(productDataForSku, 'linkedData.brand', '')}",
}`);
};
上面我试图将React地图组件添加到我的项目中但遇到错误。上面是我目前的地图组件。
答案 0 :(得分:1)
import loopSkus from './stranify';
GsranjifyQuickzLook.js
这是default
导入语法。在./stranify
中,您将导出为命名导出。将export default loopSkus
添加到./stranify
或导入为import { loopSkus } from './stranify';