In the discussion of _Yaqui Delgado Wants to Kick Your Ass_ one of the notes that was made was that the main character doesn't swear, she is sworn at. So, it is a YA book that contains, as some people like to call it, language, but it is about being bullied, about having such words directed at you.
To make an imperfect leap, a book that is currently experiencing a large amount of scrutiny has racial slurs being used in what I imagine is intended to be an adorable moment between to two lovers. It's still hurtful language, but it's especially jarring to the reader when they have reason to believe the characters are in a safe space. Yes, the characters were joking about thinks others might say, but like a lot of things of late that have fallen flat, knowing your audience is key. Using racially charged language or ableist language or homophobic language or language that belittles or others people is not off limits to authors. But putting such language in the mouths of your main characters is a big deal. And if you cannot do so in a way that doesn't harm your readers then yes, you just shouldn't. (I'm not linking to the author on this mostly because I don't want to give her more publicity. The publisher in question has apologized and taken steps to try to better catch such things in their editing process.)
Some people have suggested that you can't win, you get dinged for writing only people that look like you, you get dinged for writing people that don't look like you wrong. And well, yes, that's true. Writing people who operate like people is hard. It requires work, and thought, and research. If you don't like studying and learning about all kinds of people, you may not be ready to be a writer. I would never create a character from Nebraska without doing a lot of research since I don't know what's different or the same about Nebraska, the same is true for other choices you make about your characters.
And if you get something wrong, apologize. Learn. Grow. Because being wrong about your character's language is both the same and different then being wrong about the kind of gun they used. The same because mistakes happen. You hope to learn better for next time. Different because if you were wrong by making your characters racist or homophobic or something else, you caused actual harm to your readers. And in this patriarchal, racist, queerphobic society, readers are hoping this book is a safe space. If you screwed that up, then yeah. It's a big deal. But it's not just a big deal to you. They got betrayed by the story they were reading. So yes, there is concern when writing. That's part of the job.