TicTacMan
Testing conditional rendering in child component
Hi, I am trying to test a particular interaction in my component.
I have two components, let's call them
Parent
and Toast
.
Toast
is a child of the Parent component.
Below is a code snippet from the Toast component:
The Parent
component has a button that fires an API call. If there is an error in sending the API call, the signal that controls the visibility of the Toast
component is set to True
The problem Im facing is that the code inside the <Show> does not seem to re-render and Im not sure why. I also console.log the value of toastVisibility and I can confirm that its initially set to false and after clicking the button, its set to true8 replies
Detect which dependency changed when using "on" utility with createEffect
Hi, I have the code below:
I have a store called dataStore which is an object with 50+ properties.
I have a string array called triggerFields which correspond to the property names in dataStore.
I want this effect to only run when the trigger fields change. So far I have managed to get this to work by simple accessing the particular properties (i.e the string values in TriggerFields) of dataStore.
However now inside my effect, I actually want to figure out which of my triggerField was responsible for the effect to run.
Any ideas on how I can accomplish this?
3 replies
Is it possible to subscribe to particular properties in a object wrapped by a store?
I have a usecase in which I have an object with say 100+ properties.
I have some function which I would like to execute only when property 52 changes.
Is it possible to do something like this?
Will this function only trigger whenever the value of property52 updates? Or when any value of the data object changes?
10 replies
Is it possible to pass paramters a function wrapped by a createEffect/createMemo?
,I have a certain function in my component which I have noticed runs multiple times since I am referencing the function multiple times in my JSX.
I found that the recommended way to alleviate this problem is to wrap the function in a createMemo. However my function requires some parameters which are passed to it through its calling context.
So is there any way I can pass parameters to a function wrapped by a useEffect or useMemo?
2 replies
Is it possible to untrack writes to a signal?
I have a certain use case, in which I have a function called getTextBoxValue which needs to run at a particular time.
The way I control the execution of this function is by using a boolean signal called IsTriggerFieldChanged like a flag. So I set the value of this flag to be true, to execute my function.
The problem is that within the function, I need to reset the value of the flag back to false for it to work a second time. However when I set the flag to false, it triggers a re-execution of my function (IsTriggerFieldChanged) which undoes the calculated value
Input field which controls the function execution: https://pastebin.com/yhqyAUh9
The function that Im trying to run based on the flag: https://pastebin.com/PAxTtZ1Q
12 replies