I did not do stranger danger for two reasons DD is already painfully shy and she's more likely to be at risk from someone she knows/is comfortable with than a strangers.
As soon as she could understand we talked about staying with mummy and daddy, not wondering off, always be within sight, always ask about going further/with another child/whatever.
Then we moved to the pants rule, when it might be necessary,when it's ok (had an accident, doctor visit etc) and we used names of kids or friends or relatives before we even got to strangers.
Then we talked about someone else trying to pick her up from school ,even if it's someone she knows, without her or the teacher knowing about it. I always told if not sure,just refuse to go and have them ring me. I reinforce this by always letting her know in the morning if someone else is picking her up.
Then We had a few chats about what to do in an emergency, where to ask help if local etc.
Focusing on strangers is not necessarily wrong, but it can leave children ill equipped to deal with things if it's a friend,a classmate, another trusted adult etc.