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
13
votes
3 answers

How to add an image in Yew?

I am building a simple web app with Rust and I am trying to display an image to the website. But I can't add that image. I am using Rust with a framework called Yew and with a tool Trunk. I have successfully linked the .scss file to my website with…
Md Shanto
  • 131
  • 3
  • 4
9
votes
1 answer

Unable to execute "trunk serve"

I was getting into Rust and looking at these simple instructions for Yew framework (a frontend framework for Rust). (Found at: https://yew.rs/docs/tutorial) I followed the instructions up until the command trunk serve --open However, something…
thatVar
  • 152
  • 2
  • 7
6
votes
0 answers

Using a Yew Callback as a wasm_bindgen Closure

This question is written for Yew v0.19 Asynchronous foreign JavaScript functions can be used in Rust through Closures, as the function to pass-in: #[wasm_bindgen] extern "C" { fn setInterval(closure: &Closure, time: u32) ->…
Athan Clark
  • 3,886
  • 2
  • 21
  • 39
5
votes
2 answers

Is there a way to get system time/date inside of a yew app?

Normally in a rust app, I'd get system time with std::time::SystemTime::now(), but that doesn't seem to work in a yew app. Instead the component I'm trying to read the system time from just silently (from the server logs) fails and in the web…
4
votes
1 answer

How to pass a function as a Prop in Yew?

I simply want to pass a function to one of my children through their props so it can be used there. Here's the code I have now use log::info; use yew::html::onclick::Event; use yew::prelude::*; // Create Properties with the function I want to…
sc3000
  • 121
  • 1
  • 9
4
votes
1 answer

How to make an HTTP request using wasm_bindgen_futures inside a yew struct component that updates the state

I have a yew struct component that should make a get request to the api and then render the list of items. I'm trying to perform the request inside the render method of the component and I'm running into lifetime issues where I can't use the…
4
votes
4 answers

yew with tailwind css

I have tried to follow the steps described in https://dev.to/arctic_hen7/how-to-set-up-tailwind-css-with-yew-and-trunk-il9 to make use of Tailwind CSS in Yew, but it doesn't work. My test project folder: Cargo.toml: [package] name =…
ItFlyingStart
  • 261
  • 4
  • 13
4
votes
0 answers

How to exec js code on rust with wasm-bindgen correctly

I'm working with rust, WASM, and yew as frontend framework. I'm building a wrapper around materialize-css, to use it on yew as dependency of reusable components. To use some materialize-css components it's necesary initialize it. For example, to use…
al3x
  • 589
  • 1
  • 4
  • 16
4
votes
1 answer

how to create a grid and cells in Yew app

Yew app. I am trying to build a grid and inside grid I would like to arrange cells in Yew app. I would like to have My grid a 4*4 array Cells size would be 5px width and height I also need to set the Cell color property based on the method I solve…
Naveen
  • 109
  • 1
  • 6
3
votes
1 answer

How to set state inside listener in use_effect_with_deps?

I have an event listener inside an use_effect, there I want to get the value from mouse event and set it to a state. To add the event listener I used use_node_ref but I am getting the next error: error[E0597]: `coordinates` does not live long…
programandoconro
  • 2,378
  • 2
  • 18
  • 33
3
votes
0 answers

How to load a npm package to wasm_bindgen

I tried searching internet, couldn't find details how can I load a npm package to yew. I am trying to load @polkadot/extension-dapp ( code docs) #[wasm_bindgen(module = "/node_modules/@polkadot/extension-dapp/index.js")] extern "C" { …
Amiya Behera
  • 2,210
  • 19
  • 32
3
votes
1 answer

Failed to follow yew tutorial on Mac m1 - use of undeclared type `Vec`

Whenever I run trunk build or cargo run --target=wasm32-unknown-unknown I get a bunch of scope errors. I've already run rustup target add wasm32-unknown-unknown and cargo install --locked wasm-bindgen-cli, but still had no luck. What do these error…
metal bar
  • 522
  • 3
  • 12
3
votes
1 answer

Yew: Difficulty with nested callbacks

I'm attempting to do something that I feel is pretty basic: I have a pulldown, and I'd like the onchange event for that pulldown to cause the program to fetch some data from the backend based on the user's input. (And then, you know, give the user…
djmcmath
  • 97
  • 5
3
votes
1 answer

docker container didn't send any data

running docker build -t . then running docker run -p 8080:8080 logs to console that it works but 127.0.0.1:8080 does not display the client Dockerfile: FROM rust:1.60.0-slim-buster WORKDIR /app COPY . . RUN rustup…
apinanyogaratnam
  • 628
  • 7
  • 14
3
votes
0 answers

How to make objects draggable like notion.so?

I am trying to have dragging feature just like notion.so so when you hover on an element a dragging icon appears then you drag the entire element by dragging the icon. I tried this before with reactjs but it has a lot of limitations which is very…
Ali Husham
  • 816
  • 10
  • 31
1
2 3
8 9