Avoid first onChange #439
Answered
by
dbismut
singuerinc
asked this question in
Q&A
-
Hi, is there a way to avoid the onChange on the first render? Let's suppose I want to change the url based on the value of useControls({
slug: {
options: ["post-1", "post-2", "post-3"],
onChange: (slug) => {
alert(slug); // post-1 is shown on page load
router.push(slug) // will navigate on page load, not useful
},
},
}); I'm getting an infinite loop here. I know I could check the current url but I was wondering if is there a better solution. |
Beta Was this translation helpful? Give feedback.
Answered by
dbismut
Feb 16, 2023
Replies: 1 comment 1 reply
-
There's several arguments that onChange provides. The second or third one has an initial props that does what you want. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
singuerinc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's several arguments that onChange provides. The second or third one has an initial props that does what you want.