Questions tagged [yew]

Rust/Wasm framework for creating web applications

Yew takes inspiration from React and Redux. It uses Web Assembly and webworkers to create multi-threaded frontend apps.

The repository lives at https://github.com/yewstack/yew.

124 questions
1
vote
1 answer

[Yew-router]use_navigator() is None

I'm a beginner. I tried to using yew-router with confirming the below tutorial. https://yew.rs/docs/next/concepts/router but, it's not working. I'm getting the below error message. panicked at 'called Option::unwrap() on a None value',…
croron
  • 31
  • 3
1
vote
1 answer

How can I get the total number of files at build time and then pass it to web assembly in Yew?

I'm currently building an image carousel. I want to count the contents of a directory that is only accessible at the OS level and pass the result to a static hashmap inside a web assembly module in Yew. Here's a use_reducer paired with a Context in…
Jose A
  • 10,053
  • 11
  • 75
  • 108
1
vote
0 answers

Drag and drop in Tauri + Yew

I am having issues with handling drag and drop. I prevent_default on my drop target for both the dragEnter and dragOver events, which I can verify are firing, but the drop event is never triggered. I have also tried setting the…
bicarlsen
  • 1,241
  • 10
  • 27
1
vote
2 answers

How to import a component in Yew?

So I have a main.rs file that looks like so: fn main() { yew::Renderer::::new().render(); } But I need to import the App component into main.rs. From what I saw in a tutorial I should be able to do: use ::App;, but that does…
Daniel
  • 14,004
  • 16
  • 96
  • 156
1
vote
3 answers

How to quit "trunk serve" Rust

I just started using rust for the web and I have run into a problem where once I call trunk serve I do not know how to stop it. this must sound like the whole unable to quit vim meme...
Jove
  • 105
  • 4
1
vote
1 answer

How to get a Vec from a yew::UseStateHandle>

use gloo::console::log; use std::ops::Deref; use web_sys::FileList; use yew::prelude::*; let filelist: UseStateHandle> = use_state(|| vec![]); Callback::from(move |event: DragEvent| { event.prevent_default(); let files =…
Amiya Behera
  • 2,210
  • 19
  • 32
1
vote
0 answers

Why is the "onload" event never emitted?

I'm new to Yew and Rust, I wanted to write a component that would emit a canvas and pre-initialise it: use yew; use web_sys; #[yew::function_component(App)] fn app() -> yew::Html { yew::html!{
1
vote
0 answers

Can I use Rust / Yew / Trunk to generate just a DOM node and script for use in HTML templates?

TLDR Total n00b with rust, yew and trunk. I want to find out how to rust, yew and trunk to build an HTML file containing just one DOM node, not a whole HTML page. Background Day-to-day, I use Django, the python web framework. Its admin console uses…
thclark
  • 4,784
  • 3
  • 39
  • 65
1
vote
1 answer

How to pass argument to onclick callback - yew function component

How do I correctly pass an argument to an onclick event handler in a yew function component? What I have: #[function_component(Calculator)] pub fn calulator() -> Html { let navigator = use_navigator().unwrap(); let handle_formula_click =…
Jon Ham
  • 11
  • 3
1
vote
0 answers

yew google sign-in issues

I use yew, I want a button to appear on a webpage. I am following the official tutorial of Google : https://developers.google.com/identity/sign-in/web/sign-in here is my code:
hbkim
  • 11
  • 1
1
vote
0 answers

Add callback to element generated inside iterable

I'm trying to generate HTML of elements inside of a vector, which will have a button to remove itself (the button). Here is my code: pub struct App { pub elements: Vec } pub struct AppElement {} impl Component for App { // .. …
1
vote
0 answers

Yew - Trigger Event from another Component

I am currently trying to get to know the yew-library of rust (in combination with the component-framework "material-yew"). I've dug around the documentation a bit, but I cannot find an explanation for the given scenario: I would like to have two…
1
vote
2 answers

stdweb::web::html_element::CanvasElement from document().query_selector() in Rust

I am building a Yew webapp in Rust, and attempting to get a CanvasRenderingContext2d from a CSS selector. The issue I am having is how to convert a stdweb::web::Element into a stdweb::web::html_element::CanvasElement. My current code is this: use…
James McGuigan
  • 7,542
  • 4
  • 26
  • 29
1
vote
1 answer

How to define route as a prop to a component | yew-route

I have the following routes defined. #[derive(Routable, PartialEq, Debug, Clone)] pub enum Route { #[at("/")] Index, #[at("about")] About, #[at("/contact")] Contact, #[at("/portfolio")] Portfolio, #[at("*")] …
s1n7ax
  • 2,750
  • 6
  • 24
  • 53
1
vote
0 answers

running yew framework sample code - error: linking with `cc` failed: exit status: 1

I am trying to run the yew framework sample code and I running into this error when running cargo install trunk wasm-bindgen-cli error: linking with ``cc`` failed: exit status: 1 I am running rustc 1.60.0-nightly (2681f253b 2022-02-01) Here's the…
SomethingsGottaGive
  • 1,646
  • 6
  • 26
  • 49
1 2 3
8 9