smolovk
smolovk

Reputation: 61

How to separate yew components to different files?

I just started learning yew (frontend framework). How do i put every component in separate file, like in js frameworks. (i am using function components now)

Upvotes: 2

Views: 810

Answers (1)

smolovk
smolovk

Reputation: 61

Assuming you have a file like src/components/text.rs, create a file called components.rs, and include the module like so:

pub mod Text;

Then, in main.rs, you can mod components; allowing you to use Text elsewhere in your project with something like:

use crate::components::text::Text

Upvotes: 3

Related Questions