How to make an atom's default value relies on RecoilValue's evaluated value #1711
-
Motivation Case:
Problem:
Expected: Is there solution to this ? Maybe Expected Feature: export const StateSubmittedParams = atom({
key: "StateSubmittedParams",
default: selector({
key: "StateSubmittedParams/Default",
get({ get }) {
const date = get(StateDate);
const select = get(StateSelect);
return {
date,
select
};
}
}).toPromise()
});
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you want the search to only be initiated from actions instead of staying in sync with all upstream atom changes then you could split your parameter state to separate atoms. A "pending" atom that is updated as you edit and then transferred to a "submitted" when the search button is clicked. It looks like you're mostly doing this. However, the "submitted" atom shouldn't get the default parameters at all if the intention is to avoid any searches until the button is clicked. |
Beta Was this translation helpful? Give feedback.
If you want the search to only be initiated from actions instead of staying in sync with all upstream atom changes then you could split your parameter state to separate atoms. A "pending" atom that is updated as you edit and then transferred to a "submitted" when the search button is clicked.
It looks like you're mostly doing this. However, the "submitted" atom shouldn't get the default parameters at all if the intention is to avoid any searches until the button is clicked.