When you're camping in the wilderness, if never hurts to be prepared for potentially dangerous encounters with wildlife, and a good rule of thumb is to avoid wildlife you come across by giving them a wide berth on the trail if at all possible.
You never know what the animal's mind set is at a given time, and they may have some babies hiding nearby. And there is nothing more dangerous than a mama protecting her young! I always get real nervous when I see baby bears in the wild, because I know that means mama must be close by! Even if you are a good distance away, mama bear may still perceive you as a threat so its always a good idea to leave the area immediately to avoid what may turn into a life-threatening encounter.
Here is a link to a great You Tube video produced by Parks Canada showing some excellent tips about how to use bear repellent (pepper spray) during a close encounter with an aggressive bear. Remember, when hiking in the wilderness, always carry your pepper spray in a readily accessible area, so that it can be deployed in just a couple of seconds - you may NOT have the time to dig through your backpack looking for it in an emergency situation!
You can purchase pepper spray at most sporting goods stores, and I have heard that "Counter Assault" which uses capsaicin (a super hot chemical irritant found in some chili peppers), is one of the most reliable brands on the market!
More info can be found here > www.counterassault.com/bear-spray/