Chapter 70: staticFile()
Core Idea
Turns a file in your public/ folder into an URL which you can then load into your project.
Key Concepts
- Example
- Why can't I just pass a string?
- Getting all files in the public folder
- Handling URI-unsafe characters<AvailableFrom v="4.0.0"/>
- Compatibility
- See also
Code Examples
const myImage = staticFile(`/my-image.png`);
// ...
<Img src={myImage} />;
- What it demonstrates: Usage pattern for staticFile() from the official docs.
Key Takeaways
- Understand example when working with staticFile().
- Understand why can't i just pass a string? when working with staticFile().
- Understand getting all files in the public folder when working with staticFile().
- Understand handling uri-unsafe characters<availablefrom v="4.0.0"/> when working with staticFile().
- Understand compatibility when working with staticFile().
Connects To
- Cancel Render: related page in the Hooks & Data APIs section.
- Continue Render: related page in the Hooks & Data APIs section.
- Data Fetching: related page in the Hooks & Data APIs section.