One advantage of being the putative leader of a great nation is that people pay attention, even when you’re spouting nonsense. So it must be satisfying for Donald J. Trump, the President-elect, to fire off pensées on his Twitter account, knowing that each of these thoughts, or notions—however you describe them—will be subject to analysis. Are they true, or false, or silly? It doesn’t matter—attention must be paid, and if you thrive on attention it doesn’t get any better than that. In the past few days, along with trying to fill Cabinet posts, Trump came up with the conceit that he won the popular vote in the Presidential election, when he actually lost by more than two million votes, and that someone who exercises the constitutional right of offensive free speech by desecrating the American flag should face legal consequences; Trump suggested jail or the loss of citizenship. He continues to tweet out instant commentary on whatever crosses his mind, as he did this week, after a Somali refugee, an eighteen-year-old student at Ohio State University, attacked eleven people before being shot dead: “ISIS is taking credit for the terrible stabbing attack at Ohio State University by a Somali refugee who should not have been in our country.”

Trump’s habit is to use such occasions to condemn all refugees—men, women, and children who’ve come here from the world’s most wretched places, and who fear for their own safety—and, beyond them, millions of other immigrants whenever one is singled out as a bad actor. A year ago, after a mass shooting in San Bernardino, California, Trump called for the “total and complete shutdown” of the borders to Muslim immigrants. Last summer, after the horrific mass killing in Orlando, Florida, by a New York-born Muslim-American, Trump said, “If we don’t get tough, and if we don’t get smart, and fast, we’re not going to have our country anymore. There will be nothing, absolutely nothing, left. The killer, whose name I will not use, or ever say, was born in Afghan, of Afghan parents, who immigrated to the United States.”

It is a small step from a Presidential candidate suggesting that refugees from Islamic nations shouldn’t be allowed here to a President encouraging the Justice Department to ignore the rights granted to all citizens. There have been many mildly hysterical comparisons between Trump’s success and the rise of the twentieth century’s totalitarian dictators, but his behavior is most worrisome because Americans have seen this happen before, in America, under some of our revered, and elected, leaders.

In “Strangers in the Land,” a terrific and still relevant study of American nativism, published in 1955, the historian John Higham wrote about the time of the First World War, when the nation was on the verge of cultural and ethnic hysteria and ethnic Germans were seen as domestic enemies. When President Woodrow Wilson, on April 2, 1917, asked Congress for a declaration of war, the writers and speakers of the era were familiar with the expression “one hundred per cent Americanism,” as opposed to the hyphenated Americanism of, say, German-Americans, and there were soon suggestions that German-American Red Cross volunteers were conspiring to put ground glass in the bandages and food meant for the troops. In a Flag Day speech in June, 1917, Wilson said that Germany had “filled our unsuspecting communities with vicious spies and conspirators and sought to corrupt the opinion of our people in their own behalf.” There was a campaign to cut German-language instruction from the public schools, on the theory that the language was a way to spread un-American ideas. Sometimes a German was forced to kiss the American flag, and, one day, in April, 1918, an Illinois mob of miners lynched a German immigrant.

In May, 1918, Congress passed the Sedition Act, which amended Section 3 of the Espionage Act and outlawed certain kinds of speech and activities, among them to “willfully utter, print, write, or publish any disloyal, profane, scurrilous, or abusive language about the form of government of the United States.” That could mean a fine of ten thousand dollars and up to twenty years’ imprisonment, or both. Meanwhile, German aliens were being sent off to internment camps, the number of enemy aliens arrested on Presidential warrants rose, and stricter regulations forced German aliens to register and to get permission before moving. By 1918, the Justice Department was able to strip “disloyal” naturalized Germans of their citizenship.

The Justice Department had a staff of only three hundred investigators, so, as Higham noted, there was work to be outsourced to several “secret bodies,” one of which, the American Protective League (established by a Chicago advertising executive), became a semi-official auxiliary, with more than twelve hundred units. A.P.L. “operatives” carried out investigative assignments referred to it by the Bureau of Investigation—the precursor to the F.B.I. Their task was to report on “seditious and disloyal utterances,” which could make life especially difficult for anyone unlucky enough to have German ancestry.

That toxic history, which we all share, is always ready to bubble to the surface, as it did during the Second World War, under President Franklin D. Roosevelt, with the internment of Japanese-American citizens; in the late nineteen-forties, when President Harry Truman’s loyalty-security program began and domestic Red-hunting was in flower; and in the nineteen-sixties and early nineteen-seventies, through the F.B.I.’s Counterintelligence Program, which used illegal means to infiltrate and manipulate domestic groups.

One would hope that a President whose German grandfather, Friedrich Trump, immigrated to the U.S. in 1885, would be sensitive to any attempt to single out groups whose ancestors have, in many cases, been here for generations. But because the President-elect has shown few signs of compassion for those who most need it, the next few years may turn out to be, among other things, a time to test the strength and endurance of values that supposedly are ingrained in our heritage. Only time, and tweets, will tell.