President Donald Trump and North Korean leader Kim Jong-un are leaving Hanoi without a new deal on Thursday.

The media are already playing the result as a loss for Trump, and his critics are mocking his purported skills as a deal-maker. That only shows how little they understand negotiation.

“No deal” is better than a bad deal — and the best way to get a good deal is to show that you are willing to walk away if the other side cannot make concessions.

That is something President Barack Obama and then-Secretary of State John Kerry never understood, which is why the Iran nuclear deal was such a disaster. As the Iranians made more demands, the allies made more concessions, and the Obama administration was reduced to arguing that the only alternative to accepting the deal was war. In the end, Obama subverted his own country’s Constitution, evading the Senate and using the UN to impose the deal.

The prospects for a deal looked good in Hanoi until the end. Kim Jong-un told reporters that he had accepted the principle of denuclearization. The devil was in the details.

Trump played the meeting well, making it clear that he wished to have good relations with North Korea. In the end, Trump said, the North Koreans wanted a total lifting of sanctions in return for partial denuclearization. He said no.

It was a stark contrast to Obama, who lifted many sanctions on Iran before talks on a final deal began. Trump told reporters in Hanoi: “You always have to be prepared to walk.”

He added: I could have signed an agreement today, and then you people would have said, ‘Oh, what a terrible deal.’ … I’d much rather do it right than do it fast.”

The example of Ronald Reagan walking away from Mikhail Gorbachev at Reykjavik comes to mind.

FLASHBACK: @RollingStone in 1986: “Reagan Flubs Reykjavik” — “Reagan came home empty-handed from Iceland, and for once he was wearing the black hat — the man who said no to a historic opportunity.” https://t.co/PyM3sEi2jj #TrumpKimSummit — Joel B. Pollak (@joelpollak) February 28, 2019

The two sides will likely meet again.

In the interim, the media ought to engage in some overdue introspection. They predicted Trump would not hold firm. They were wrong.

This does not look like the product of someone in the midst of trying to drive a hard bargain on an existential threat to U.S. national security and willing to walk away if the deal isn’t good enough. https://t.co/QVRFnpuUd1 — David Nakamura (@DavidNakamura) February 27, 2019

“Sometimes you have to walk and this was just one of those” — Trump on deciding against an agreement with Kim. — Jonathan Allen (@jonallendc) February 28, 2019

Trump says Kim agreed to dismantle Yongbyon but that it wasn't enough: "That facility, while very big, it wasn't enough to do what we were doing. We had to have more than that." — Eli Stokols (@EliStokols) February 28, 2019

Having reporters shout at Trump about Michael Cohen’s testimony on Capitol Hill — amplifying Democrats’ efforts to bring down the president — weakened Trump’s leverage in negotiations.

The principle that politics stops at the water’s edge ought to apply to journalists, too. More is at stake than clicks and retweets.

Joel B. Pollak is Senior Editor-at-Large at Breitbart News. He is a winner of the 2018 Robert Novak Journalism Alumni Fellowship. He is also the co-author of How Trump Won: The Inside Story of a Revolution, which is available from Regnery. Follow him on Twitter at @joelpollak.