I'm learning React Router (protected routes, to be precise) and in React Router documentation there is a function which I almost understand but there is one line of code which I can't see how it works. Maybe someone can shortly describe what that line does. Below is a function from https://reactrouter.com/web/example/auth-workflow
function LoginPage() {
let history = useHistory();
let location = useLocation();
let { from } = location.state || { from: { pathname: "/" } };
let login = () => {
fakeAuth.authenticate(() => {
history.replace(from);
});
};
What does this line do?
let { from } = location.state || { from: { pathname: "/" } };
I understand that we are creating an object but what does ||
do? Is it connecting two objects into one? I don't get it.