As primary season advances, Republican incumbents seeking reelection have to make a careful political calculation when it comes to President Donald Trump.

Many candidates are portraying themselves as closer to the president than their primary opponents and fully backing the Trump agenda, which is hugely popular among their base. Others have quit, arguing on their way out of office that the Grand Old Party has become anathema to their values.

Mark Sanford, the two-term South Carolina congressman and outspoken Trump critic, chose the third option and in doing so may have demonstrated to other Republican incumbents the political perils of crossing President Donald Trump.

Before the polls closed, Trump tweeted, "Mark Sanford has been very unhelpful to me in my campaign to MAGA. He is MIA and nothing but trouble." He then gave his full endorsement to Sanford's challenger, tweeting, "VOTE Kate!"

Trump later explained his "political representatives" didn't want him to weigh in on the race, but he felt strongly about Arrington and decided to "give it a shot."

Sanford's campaign hit a number of snags, including resurgent attacks on him for an extramarital affair he had when he was governor. Surrounded by supporters and family, Sanford acknowledged his criticism of Trump on issues of style and substance contributed to his defeat.

"It may have cost me the election in this case but I stand by every one of those decisions to disagree with the president," he said.

Arrington described the mood succinctly in her victory speech, telling the crowd, "We are the party of Donald J. Trump."

In Virginia, another Trump-endorsed candidate, Corey Stewart, won a three-way Republican primary.

In his victory speech, Stewart invoked themes from President Trump's 2016 campaign, and was interrupted by supporters chanting, "Build the wall" and "lock her up." Stewart will now run against Tim Kaine, the incumbent Democratic senator and Hillary Clinton's 2016 running mate.

Trump congratulated Stewart with a tweet, telling his followers, "Don’t underestimate Corey, a major chance of winning!"

On Wednesday, the House Republican leadership downplayed the notion that an incumbent's criticism of Trump might seal their political fate.

House Speaker Paul Ryan dismissed President Trump's late intervention in the race with the sentiment that you win some you lose some. "That’s just what happens in contested primaries," he told reporters.

Majority Whip Steve Scalise of Louisiana noted that "each race is different, especially when you talk about primaries."

"Ultimately, everybody gets held accountable each two years to the voters that we represent," he told Circa.

For Republican incumbents, they are accountable to voters who overwhelmingly support President Trump. Nationally, Trump's approval rating has been inching up around 40 percent. Among registered Republicans and likely GOP voters, his approval rating is above 80 percent.

"It's Trump's party now, fundamentally," said Geoffrey Skelley, a political analyst and the associate editor of Sabato's Crystal Ball at the University of Virginia Center for Politics. "There's no question that being a critic of President Trump right now maybe bad for your political health if you're a Republican member of Congress."

In many respects, this is not a new dynamic. As soon as the president gets the party's nomination, he becomes the standard-bearer, his agenda becomes the party's agenda and downstream candidates tend to model themselves on the president, in style and substance.

A number of elements of Trump's agenda, including trade, tariffs and relations with long-time U.S. allies broke with Republican Party orthodoxy and left many conservative lawmakers uneasy and privately sniping. Conservatives have also been circumspect and often silent in response to the president's controversial tweets about race, immigration, women or the justice system.

The Republicans who have been the most outspoken against President Trump are largely stepping down from office at the end of 115th Congress. "I don't think that's a coincidence," Skelley noted.

On Tuesday, retiring Sen. Bob Corker of Tennessee lashed out at his party's leadership for blocking a popular amendment because they did not want to "upset the president."

Paraphrasing the Republican leadership, Corker gave a fiery speech on the Senate floor. "'We might poke the bear,' is the language I've been hearing in the hallways... The president might get upset with us as United States senators if we vote on the Corker amendment so we're going to do everything we can to block it."

The Corker amendment required the president to get congressional approval before imposing tariffs, a measure Corker estimated "95 percent of the people on this [Republican] side of the aisle support intellectually."

Sen. Jeff Flake of Arizona, an even more outspoken Trump opponent, explicitly cited the changes in the Republican Party when he announced he would not seek a third term in the Senate.

In the Trump era, he explained, "a traditional conservative who believes in limited government and free markets, who is devoted to free trade, and who is pro-immigration has a narrower and narrower path to nomination in the Republican party—the party that for so long has defined itself by belief in those things."

Paris Dennard, a conservative commentator and Republican strategist is not surprised that the "Never Trumpers" are launching attacks as they leave office.

"They get this courage on the way out, and I don't necessarily call that courage," he said. "They wouldn't be doing that if they were running for reelection. You know why? Because the people don't support it."

Dennard explained that criticizing the president is not necessarily a political death sentence for Republican incumbents. Another South Carolina lawmaker, Sen. Lindsey Graham, has been critical of Trump, but when it comes to advancing his agenda, Graham has found ways to work with the White House.

Similarly, Sen. Rand Paul of Kentucky has balanced his policy disagreements with the demands of his constituents.

There's a difference between those Republican critics and the ones who are attacking the president on their way out of office, he said. "They stay in the fight. They don't just cut and run because it's too hot in the political kitchen."

Rep. Carlos Curbelo of Florida, is walking a similar path. Curbelo has often been critical of Trump. He is also among the moderate Republican insurgents pushing for a vote on an immigration bill to protect DACA recipients.

Curbelo said he believes "there's a healthy balance" between challenging the president when he is wrong, but also being willing to work him.

"You want to try to coordinate with the White House as much as possible, but you also call it honest," he told Circa.