Hello , The style of hub you have on your truck is a pulse vacuum style hub, it works alot like the clicker on a ball point pen, a solenoid that is attached to engine vacuum is energized to allow a pulse of vacuum to reach the hub and draws in a plunger and locks (click). a disengagment signal works in the same fashion. If you have a leak in the bearing portion of the hub then yes the hub will have to be replaced, If the clicker portion of the lock-out is mechanically damaged, you can just replace the lock-out portion.
Here is a technical service bullitin that may help you
Some vehicles may exhibit intermittent or no 4X4 engagement, even while the 4X4 lamp is illuminated, and/or a "clunking" noise may be heard while shifting into 4X4 on the fly. This may be caused by:
Diagnose and repair the vehicle using the following Pulse Vacuum Hub Lock (PVH) Diagnostics and Repair Procedure
Follow the pinpoint vacuum leak tests for proper diagnostic procedures.
When a customer states the vehicle exhibits noise when shifting into 4X4 HIGH on the fly, certain areas should be diagnosed. Remember that 4X4 instrument panel light illumination and front driveshaft/front axle shaft rotation are not the sole indicators of 4X4 engagement. Target areas to examine here are:
The 4X4 LOW function can only be engaged or disengaged by doing the following:
Many 1998 Ranger 4X4 customers have reported 4X4 LOW issues when they have not met all four requirements. Review these requirements with customers to determine whether they have followed the proper engagement procedures.
Oh, sorry I did't mean to throw a bunch of technical stuff at you then! The answer is yes you can replace just the outside plastic pieces, but you will need six metalic special service tools to release the old hubs. Below is approximately what you might expect to pay for this repair
.8 equals 8 tenths of an hour times whatever the shop hourly rate is at your mechanics shop!