How I work with unfamiliar libraries
When working with libraries I haven’t worked with before, examples help me the most. Using Sourcegraph, I can search millions of public repositories for where they are importing or using the same library as me. Usually, you’ll find someone doing what you want to do!
For example, I tried to use Astro’s <Picture />
component for my blog but didn’t know how to use the sizes
attribute. Using Sourcegraph, I found a test doing exactly what I needed.
<Picture
src={heroImage}
width={720}
height={360}
alt=""
sizes="100vw"
widths={[720]}
aspectRatio={720 / 360}
formats={["avif", "webp"]}
loading={"eager"}
/>