When clicked from the button component, I set the id, then I pass this id into the Redux-Toolkit Query request, but id is initially null. How can I do the check?
// id maybe null
const { id } = useSelector(userSelector)
const { data } = useGetUserQuery({ id });
Maybe props in up level.
If I'm correct in understanding that you really want to only make query requests for non-null
idvalues then you can use askipparameter or askipTokento wait untilidis non-null, or truthy.See Conditional Fetching
or
If you don't want the query to run for any falsey
idvalue, e.g.null,undefined,"",0, etc, then the above can be simplified a bit.or