Created
March 3, 2020 19:43
-
-
Save FDSoftware/2e72762eda66d1ce98698db9a69d2be1 to your computer and use it in GitHub Desktop.
TypeScript y sus bugs falopa con functional component , en este caso props default y interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable jsx-a11y/alt-text */ | |
import React from "react"; | |
// Related issue https://github.com/microsoft/TypeScript/issues/36433 | |
interface myProps { | |
imgData?: { | |
username: string, | |
title: string, | |
url: string | |
} | |
} | |
const defalutProps2 = { | |
imgData: { | |
username: "CBSAllAccess", | |
title: "Season 5 Whatever GIF by CBS All Access", | |
url: | |
"https://media3.giphy.com/media/kF6feGLva6p05Bg52U/giphy.gif?cid=a4809b61479a04e2c2ce1d6cb68970a008d6acd4a736e9ff&rid=giphy.gif" | |
} | |
}; | |
const GIF = ({imgData = defalutProps2.imgData} : myProps ) => { | |
console.log(imgData) | |
return ( | |
<> | |
<p>{imgData.title}</p> | |
<img src={imgData.url} /> | |
</> | |
); | |
}; | |
export default GIF; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment