Skip to content

How to call use_effect? #10

Closed Answered by yishn
ChocolateLoverRaj asked this question in Q&A
Discussion options

You must be logged in to vote

You have to wrap your effect code in the closure and return a destructor (see also documentaiton):

use_effect(move || {
  log_1(&"...".into());

  || ()
}, Deps::none());

With v0.6 you do not need to return anything to imply a noop destructor || ():

use_effect(move || {
  log_1(&"...".into());
}, Deps::none());

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ChocolateLoverRaj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants