Conversation
Markers view will be fixed in when I link Map with our API to get location data.
| let coord : Coord =[0,0] | ||
| const addressesList = await response; | ||
|
|
||
| addressesList.forEach((house:House, i:number) => { |
There was a problem hiding this comment.
i doesn't need its type to be specified.
There was a problem hiding this comment.
TS shout when type is undefined.
|
|
||
| addressesList.forEach((house:House, i:number) => { | ||
| const address = `${house.city} ${house.streetNumber} ${house.streetName}`; | ||
| geocoder.geocode({ address }, (results:[{geometry:{location:{lat:()=>number,lng:()=>number}}}], status:string) => { |
There was a problem hiding this comment.
I know it's WIP but the type of this complexity: [{geometry:{location:{lat:()=>number,lng:()=>number}}}] would be best declared outside of this function, like you did with House as it makes it easier to read.
src/components/Map/GoogleMapComp.tsx
Outdated
|
|
||
| export default function GoogleMapComp({ houses, style }:{houses:House,style:CSS.Properties}) { | ||
| function Map() { | ||
| let [housesCoords, setHousesCoords]:[Coord[],Dispatch<SetStateAction<Coord[]>>] = useState<Coord[]>([]); |
There was a problem hiding this comment.
You don't have to declare the types of [state, setState] right after declaring them as TS will know their types thanks to the way it works with React, so
let [housesCoords, setHousesCoords] = useState<Coord[]>([]);
will do and using const instead let would be advisable. Sometimes you don't have to declare the type even inside the <> after useState but it's generally a good practise to do so even when the type of a state can be guessed from an initial value of a state.
src/components/Map/GoogleMapComp.tsx
Outdated
| function Map() { | ||
| const [housesCoords, setHousesCoords] = useState([]); | ||
|
|
||
| export default function GoogleMapComp({ houses, style }:{houses:House,style:CSS.Properties}) { |
There was a problem hiding this comment.
It could be a good idea to declare an interface or type with {houses:House,style:CSS.Properties} above the function to make it easier to read.
No description provided.