Question: I've set my mapping up as follows:

```
CreateMap<SourceClass, DestinationClass>().ForMember(destinationMember => destinationMember.Provider,
                memberOptions => memberOptions.MapFrom(src => src.Providers.FirstOrDefault()));

```

Where I'm mapping from a List in my SourceClass to a string in my destination class.

My question is, how can I handle the case where "Providers" is null?

I've tried using:

`src?.Providers?.FirstOrDefault()`

but I get an error saying I can't use null propagators in a lambda.

I've been reading up on Automapper and am still unsure if AM automatically handles the null case or not. I tried to build the expression tree, but was not able to see any information that provided additional informations.

If it helps, I'm using automapper v 6.1.1.

Answer: 
Like what @goto1 mentioned in a comment, you may create a custom hook to use for a cleaner and reusable look. Here's my take on a custom hook called `useCbOnce` which calls any event callback once:

```
const useCbOnce = (cb) => {
    const [called, setCalled] = useState(false);

    // Below can be wrapped in useCallback whenever re-renders becomes a problem
    return (e) => {
        if (!called) {
            setCalled(true);
            cb(e);
        }
    }
}

const MyForm = (props) => {
    const handleSubmit = useCbOnce((e) => {
        e.preventDefault()
        console.log('submitted!')
    });
    return <form onSubmit={handleSubmit}>...</form>;
}

```
You can reuse `onSubmit` logic with simple [custom hook](https://reactjs.org/docs/hooks-custom.html#using-a-custom-hook).

I oversimplified the logic so it won't cause unnecessary renders:

```
const useOnSubmit = () => {
  const [, setSubmitted] = useState(false);

  const onSubmit = useCallback(e => {
    e.preventDefault();
    setSubmitted(prevState => prevState || !prevState);
  }, []);

  return onSubmit;
};

// Usage
const onSubmit = useOnSubmit();
<form onSubmit={onSubmit}>...</form>

```