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
fn main() { | |
println!("Guess the number!"); | |
let secret_number = rand::thread_rng().gen_range(1, 101); | |
println!("The secret number is: {}", secret_number); | |
println!("Please input your guess."); | |
let mut guess = String::new(); |
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
{ | |
"data": { | |
"getInt": 12, | |
"getString": null | |
}, | |
"errors": [ | |
{ | |
"message": "Failed to get string!", | |
} | |
] |
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
<div id="my-component"> | |
<header> | |
<!-- children with the `slot="header"` attribute will go here --> | |
<slot name="header" /> | |
</header> | |
<main> | |
<!-- children without a `slot` (or with the `slot="default"`) attribute will go here --> | |
<slot /> | |
</main> | |
<footer> |
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
--- | |
export interface Props { | |
post: any; | |
} | |
const { post } = Astro.props; | |
--- | |
<article class="post-preview"> | |
<header> |
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
<section> | |
{allPosts.map(p => <BlogPostPreview post={p} />)} | |
</section> |
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
--- | |
// Import your components in your component script... | |
import SomeComponent from './SomeComponent.astro'; | |
--- | |
<!-- ... then use them in your HTML! --> | |
<div> | |
<SomeComponent /> | |
</div> |
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
function DogPhoto({ breed }) { | |
const { loading, error, data, refetch } = useQuery(GET_DOG_PHOTO, { | |
variables: { breed } | |
}); | |
if (loading) return null; | |
if (error) return `Error! ${error}`; | |
return ( |
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
function DogPhoto({ breed }) { | |
const { loading, error, data } = useQuery(GET_DOG_PHOTO, { | |
variables: { breed }, | |
pollInterval: 500, | |
}); | |
if (loading) return null; | |
if (error) return `Error! ${error}`; | |
return ( |
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
function DogPhoto({ breed }) { | |
const { loading, error, data } = useQuery(GET_DOG_PHOTO, { | |
variables: { breed }, | |
}); | |
if (loading) return null; | |
if (error) return `Error! ${error}`; | |
return ( | |
<img src={data.dog.displayImage} style={{ height: 100, width: 100 }} /> |
NewerOlder