Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

Read JSON from local file but error on map function

$
0
0

I followed a few articles on how to read json data from a local file in React and they are recommending using map function. Like https://morioh.com/p/316b1492cfda

I am getting an error

Property 'map' does not exist on type '{ updated: number; }'.ts(223)

Here is my code

import UpdatedFile from '../public/updated.json';const[Updated,setUpdated]= useState("9/9/2020");  const newdata = UpdatedFile.map((data) =>{  // This is where the error is coming    return (      setUpdated({map.updated})    )      });

This is how my JSON file looks like.

{"updated": 1599692605913}

Any idea why its not recognizing map as a valid function?


Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>