I am having an error whenever I map inside a function to call data from array. you can see my code below.
onAddOrder = () => {
var newOrders = this.state.orders;
newOrders.push({
parts: [],
prints: {_.map(this.state.selectedOrder.prints, (print) => {
return {
name: {print.printMethod},
width: {print.width},
height: {print.height},
colors: {print.colors}
};
})},
breakdown: [{
size: '',
quantity: 0
}]
});
this.setState({
orders: newOrders
});
}
and here is the error I have
Module build failed: SyntaxError: /Users/dczii/Projects/dashboard/src/components/OrderForm/OrderForm.js: Unexpected token (156:18) <br />
154 | },<br />
155 | parts: [],
> 156 | prints: {_.map(this.state.selectedOrder.prints, (print) => {
| ^
157 | return {
158 | name: {print.printMethod},
159 | width: {print.width},
You may have confused of JSX expression block {}
. It is used between JSX tags (like <a>{someExpression}</a>
) and you don't have to use it in plain JavaScript, if that was your intention.
I just removed curly braces and see it works