#I need a reducer example

9 messages · Page 1 of 1 (latest)

dark summit
#

so in Qwik you use signals, which means you mutate values directly, so you don't really use reducers.

proper pebble
#

use signals cannot be used like reducer in general. Is there a method or example of managing all states from somewhere?

dark summit
#

So far I've not needed that. Can you give an example of what you would normally do?

proper pebble
#

FOR EXAMPLE, there will be a form input somewhere on my site, you will enter your phone number and it will direct you to the main form page, but when you redirect, I want to send the phone number you entered there to the page we redirected. In short, the simple reducer logic in React is to control all the states from one place, not by always passing props.

viral garden
proper pebble
#

Even though I made the same code in the example, I get these errors.
Code(20): Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.

Error: Code(20): Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.

Uncaught Error: Code(20): Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.

Code(13): Actual value for useContext(docs.theme-context) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized. docs.theme-context Error: Code(13): Actual value for useContext(docs.theme-context) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized.

Code(13): Actual value for useContext(docs.theme-context) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized. Error: Code(13): Actual value for useContext(docs.theme-context) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized.

verbal needle
dark summit
proper pebble