Skip to content

Commit

Permalink
fix: typing + functions as components
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Sep 14, 2023
1 parent 1ab9307 commit dd905bb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
10 changes: 6 additions & 4 deletions components/lands/buildings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement, useMemo } from "react";
import React, { FunctionComponent, ReactElement, useMemo } from "react";
import { TextureLoader, RepeatWrapping, NearestFilter, Vector2 } from "three";
import { BuildingTileProps } from "../../types/land";
import BuildingItem from "./buildingItem";
Expand All @@ -10,10 +10,10 @@ type BuildingsProps = {
buildingData: (BuildingTileProps | null)[][];
};

export default function Buildings({
const Buildings: FunctionComponent<BuildingsProps> = ({
tilesets,
buildingData,
}: BuildingsProps): ReactElement | null {
}) => {
const buildingTexture = useMemo(() => {
const texture = useLoader(
TextureLoader,
Expand Down Expand Up @@ -56,4 +56,6 @@ export default function Buildings({
})}
</>
);
}
};

export default Buildings;
11 changes: 5 additions & 6 deletions components/lands/ground.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement, useMemo } from "react";
import React, { FunctionComponent, ReactElement, useMemo } from "react";
import {
TextureLoader,
RepeatWrapping,
Expand All @@ -16,10 +16,7 @@ type GroundProps = {
cityData: (GroundTileProps | null)[][];
};

export default function Ground({
tileset,
cityData,
}: GroundProps): ReactElement | null {
const Ground: FunctionComponent<GroundProps> = ({ tileset, cityData }) => {
const groundTexture = useMemo(() => {
const textObj = useLoader(
TextureLoader,
Expand Down Expand Up @@ -57,4 +54,6 @@ export default function Ground({
})}
</>
);
}
};

export default Ground;
12 changes: 7 additions & 5 deletions components/lands/roadProps.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement, useMemo } from "react";
import React, { FunctionComponent, ReactElement, useMemo } from "react";
import {
TextureLoader,
RepeatWrapping,
Expand All @@ -11,17 +11,17 @@ import { Tileset } from "../../types/ldtk";
import { useLoader } from "@react-three/fiber";
import RoadItem from "./roadItem";

type RoadItemProps = {
type RoadItemsProps = {
tilesets: Tileset[];
cityData: (RoadObjects | null)[][];
tileData: TileData[];
};

export default function RoadProps({
const RoadProps: FunctionComponent<RoadItemsProps> = ({
tilesets,
cityData,
tileData,
}: RoadItemProps): ReactElement | null {
}) => {
const buildingTexture = useMemo(() => {
const texture = useLoader(
TextureLoader,
Expand Down Expand Up @@ -84,4 +84,6 @@ export default function RoadProps({
})}
</>
);
}
};

export default RoadProps;

0 comments on commit dd905bb

Please sign in to comment.