Your object structure is incorrect. You need to put 1
and 2
on the same level of object ob
:
const ob = {
"1": [{
"name": "destination"
}],
"2": [{
"name": "destination"
}]
};
console.log(ob['1']);
console.log(ob['2']);
More Related Contents:
- Detect click outside React component
- When to use ES6 class based React components vs. functional ES6 React components?
- Why and when do we need to bind functions and eventHandlers in React?
- React-Router: No Not Found Route?
- What is the right way to use Jquery in React?
- How to async await in react render function?
- Invariant Violation: _registerComponent(…): Target container is not a DOM element
- Error: [PrivateRoute] is not a component. All component children of must be a or
- What is the difference between React Native and React?
- Objects are not valid as a React child (found: [object Promise])
- React – getting a component from a DOM element for debugging
- ReactJS SyntheticEvent stopPropagation() only works with React events?
- React | How to detect Page Refresh (F5)
- Do I have to store tokens in cookies or localstorage or session?
- When should I use brackets with imports
- How to handle calling functions on data that may be undefined?
- Uncaught Error: Invariant Violation: findComponentRoot(…, …$110): Unable to find element. This probably means the DOM was unexpectedly mutated
- I am getting error in console “You need to enable JavaScript to run this app.” reactjs
- I can’t reference an image in Next.js
- Update one of the objects in array, in an immutable way
- What does useCallback/useMemo do in React?
- How to hide bottom navigation bar on a specific screen in react native?
- Use Object.assign or Spread Operator in React/Redux? Which is a better practise
- Do we still need functional setState way in react hooks?
- Reactjs-setState previous state is the first argument, props as the second argument
- How to properly use useHistory () from react-router-dom?
- React Error: “SharedArrayBuffer is not defined” in Firefox
- Object is not extensible error when creating new attribute for array of objects
- How to set iframe content of a react component
- How should I alternate componentWillMount()?