-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fabi0o solution #3
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,26 @@ | |||
import { Viking } from "../types/viking"; | |||
import styles from "../styles/VikingCard.module.css"; | |||
const VikingCard = ({ viking }: { viking: Viking }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lack of whitespace in all places. The code is hard to read as there is too few "enters" used. It applies to all your code, not only this file :)
module.exports = nextConfig | ||
}; | ||
module.exports = nextConfig; | ||
module.exports = withYAML(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You replaced our custom next config with that function, so we lost it.
</div> | ||
<div> | ||
Fight with | ||
{viking.canFightWithSword |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I am not a huge fan of chaining ternary operators that way.
const jsonVikingList: Array<Viking> = vikingsJSON.map((vikingJSON) => { | ||
const fullViking = { | ||
fullName: vikingJSON.fullName, | ||
presenceOfChildren: vikingJSON.hasSon ? true : false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to return true or false from ternary operator, as the condition is already a boolean.
export const handleVikingList = ( | ||
vikingsJSON: Array<vikingDataJSON>, | ||
vikingsYaml: Array<vikingDataYaml> | ||
) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could write return type here (: Viking[]) and then you could remove all those Array from inside the function and it would work. You don't have to use type assertion everywhere for every variable, Typescript is clever enough to infer that :)
</footer> | ||
<div className={styles.head}> | ||
<h1>Hello Ragnar!</h1> | ||
<Link href={"http://localhost:3000/vikings"} className={styles.headLink}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to use host here in the url.
import VikingCard from "../components/VikingCard"; | ||
import style from "../styles/Vikings.module.css"; | ||
const VikingsList = () => { | ||
const vikingList: Array<Viking> = handleVikingList(vikingsJSON, vikingsYAML); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type is not needed, as function return is already typed.
Solution for the task with backend and frontend