I am new in react I am fetching my JSON which is
{atomic-number: 98, group: null,molar-mass: 251, name: "Californium", period: 7, symbol: "Cf", _id: "5d90ab91d84d48bff5ef7c59"}
I am passing data as props and it is inside props.elements I can get all the data but I am unable to destructure atomic-number. Here is the code
import React from 'react';
const Element = props => {
const { _id, category, group, period, symbol, name, atomic-number } = props.elements;//here it creates error for atomic-number
console.log(props.elements);
return (
<div key={_id}>
<div key={name}>{name}</div>
<div key={category}>{category}</div>
<div key={group}>{group}</div>
<div key={period}>{period}</div>
<div key={symbol}>{symbol}</div>
</div>
);
};
export default Element;