After Donald Trump's election in 2016, numerous world leaders expressed concern to President Barack Obama.

During Obama's last foreign trip, Chinese President Xi Jinping warned about how the world would view "an immature leader," a former deputy national security adviser wrote in a new memoir.

Trump has had rocky relations with China, even as he has lavished praise on Xi.

Days after Donald Trump won the 2016 US presidential election, Barack Obama left the country for his last trip abroad as president.

The trip took him to Greece, Germany, and finally Peru, where he attended the 2016 Asia-Pacific Economic Cooperation summit. Throughout the trip, anxious world leaders greeted Obama, inquiring about the man who would soon occupy the Oval Office.

That sentiment was on display in Lima, where "Obama was pulled aside by leader after leader and asked what to expect from Donald Trump," former deputy national security adviser Ben Rhodes wrote in his memoir of his time in the White House, "The World as It Is."

Obama advised them to give the Trump administration a chance, telling them to "wait and see," Rhodes said.

Obama and Chinese President Xi Jinping toasting at a banquet in Beijing's Great Hall of the People. REUTERS/Greg Baker/Pool

The trip featured a sit-down meeting between Obama and China's president, Xi Jinping.

Two years before, the two met in China, where Obama secured Xi's cooperation to address climate change, which in turn made the Paris climate accord possible.

Xi told Obama — unprompted, Rhodes said — that China would implement the Paris accord even if Trump abandoned it.

Obama called that decision wise and said Xi could expect "states, cities, and the private sector" in the US to continue investing in the accord, even if the federal government reneged.

As the meeting came to an end, Xi asked about the leader who would soon take over in Washington. Obama repeated his advice to wait and see, but he added that Trump had rallied US voters around real concerns about economic relations with China.

"Xi is a big man who moves slowly and deliberately, as if he wants people to notice his every motion," Rhodes said. "Sitting across the table from Obama, he pushed aside the binder of talking points that usually shape the words of a Chinese leader."

"We prefer to have a good relationship with the United States," Xi said, folding his hands in front of him, Rhodes wrote. "That is good for the world. But every action will have a reaction. And if an immature leader throws the world into chaos, then the world will know whom to blame."

Xi and Trump at Trump's Mar-a-Lago estate in Palm Beach, Florida in April 2017. Carlos Barria/Reuters

Rhodes did not elaborate on that interaction. But the months since Trump took office have been marked by rocky relations with the world, and China is no exception.

On more than one occasion, Trump has lavished praise on Xi, including calling him "a very special man" during a state visit to Beijing in November and complimenting his abolition of term limits earlier this year.

"He's now president for life," Trump said of Xi, adding, "And he's great."

Trump has even praised Xi amid the escalating trade fight between the US and China. That clash hit a new height on Friday, when Trump announced tariffs on billions of dollars' worth of Chinese goods.

"In light of China's theft of intellectual property and technology and its other unfair trade practices, the United States will implement a 25 percent tariff on $50 billion of goods from China that contain industrially significant technologies," Trump said in a statement.

Xi and Trump in Beijing. REUTERS/Thomas Peter

China said that its response to the tariffs would be immediate and that it would "take necessary measures to defend our legitimate rights and interest."

Countries around the world, especially US allies, continue to regard Trump with concern, uncertain of his commitment to longstanding alliances.

In China, Trump's seeming withdrawal from the US's traditional role on the world stage is seen as an opportunity, according to former Australian Prime Minister Kevin Rudd, but not one without risks.

Chinese leaders "see vacuums and spaces opening up around the world," Rudd said in May. "The Chinese see this as an opportunity to frankly — I won't say exploit American weaknesses — but simply to move into vacuums."

"Here's the qualifying point," Rudd added. "They find Trump strategically comforting and tactically terrifying, and why do I say that? Tactically terrifying because they actually do not know which way he will jump."