There are two nut bolts of the derailer hanger which can easily be tightened and loosed by screwdriver and hex key, riding for long mileages through hard and aggressive terrains would result in the loosening of these two nuts due to which the derailer loses its actual hanging position and it moves and wobbles right or left side, on every bump of the trail it starts hitting with the spokes of the rear wheels, you have to adjust these two nuts and tight both of them to give an accurate hanging position to the derailer to prevent slapping with the wheel spokes.
And the other major reason is that many times it happens with the derailer hangers, these would bend and deform from the upper or lower jockey wheel ends and also from the central area, it only happens when the derailer is too old or if you have got a crash or hit on the trails due to which the derailer slightly bent, you need to correct the bending of the derailer and it needs proper truing if you know the skill then do it in your home, if not then take your bike or uninstalled derailer hanger through any mechanic shop.
It is easier to accurate the bending of derailer and hanger by using just both of your hands but the derailer is attached and connected with the frame of your bike, so truing and adjusting of derailer also affect the bike frame and the screws, but if the frame of your bike is of made up of steel then without uninstalling of the derailer you can easily true the derailer in the mounted state, but if the frame of your bike is made up of aluminum and carbon metal, these two materials are not firm and durable as much as steel, and you have to unmount the derailer from the frame for its maintenance.
The derailer hanger is totally responsible for the bending of the derailer and slapping and lining of the chain, and when the chain loses its accurate lining it constantly moves the derailer inward and outward position, as a result, the derailer starts hitting the spokes of the rear wheel, hanger is that part of the derailleur which is easily replaced and maintained because mostly the derailleur would not cause any issue, these hangers would be bent and affect the chain lining, you can easily change the hanger with a new one and also the old hanger is adjustable and maintained easier if you know the skill properly.
It is round in shape and its shape resembles the same as that of the rotors of the disc brakes but it is not a rotor. it is adjusted and installed before the cassette of the rear wheel, it has higher upper and lower edges and the main function of the dork disc is to prevent the derailleur, derailleur hanger, rear cassette, and chain from slapping and hitting the spokes of the rear wheels. if your rear wheel and derailleur have the same problem of hitting with the spokes, then install a dork disc in the rear wheel, it is cheap, even old used dork disks would also perform better by preventing these issues.
Minimum Gear Cassette:
less number of gears on a cassette also causes bending of the derailleur hanger as compared to a large gear cassette. old freewheel bikes have 7-speed cassettes but new modern cassettes have 11 and 12-speed cassettes. this hitting of the derailleur with the spokes is common in old bike wheels as compared to modern wheelsets with a larger number of gears.
When the chain shifts in the lowest cog cassette then there are more chances the derailleur of the rear wheel would come nearer the spokes of the rear wheel, this is the common issue of the two bolts of the derailleur through which the distance of the derailleur from the spokes is maintained accurately.
Length Of Chain:
Many times it happens when your bike has a smaller length of chain installed in the cassette and the derailleur, it also affects the derailleur and hanger and causes bending and deforming due to more stress and force of the smaller sized chain. when you change the gear from the smaller to larger cog by pulling the thumb shifters, then you will notice the chain gains too much stress and starts bending the hanger, as a result, the derailleur hanger pushes itself in an inward direction of the wheel toward the spokes. if you have got stuck in this problem of the smaller size of chains on the terrain or across the countryside, then shift the chain in the down smaller cog of the cassette and avoid larger cog cassette.
Loose spokes would also cause the wheel to wobble, as a result, the wheel comes nearer to the derailleur hanger, check the tensioning of the spokes and tight the screwing and threading of the spoke nipples.
Cracked Seat Tube Of Frame:
If the seat tube is cracked or has a deep scratch, then it will also cause the derailleur to hit the spokes of the rear wheel.
Higher Load On A Bike:
If the spokes have loose tension and the derailleur hanger is bent and deformed, then avoid lifting heavier loads on the same bike, but if the bike is loaded then must avoid changing gears with a loaded bike, because it negatively affects the derailleur, derailleur hanger, cassette of the rear wheel.
Sometimes it is common with mountain bikers on uphill terrains, the cup and cone bearings of the rear wheels are not working properly and these are loosely attached to each other due to which the rear wheel is constantly wobbling under a heavy load and come close to the derailleur which is causing hitting and rubbing with the spokes of the wheel.
It occurs when you want to check or solve the issue without giving and loading on the bike then this issue is hidden and invisible, it is only seen and observed when you are sitting and riding on your bike. it can be easily solved and maintained by uninstalling the rear wheel and replacing the inner bearings of the hub and axle with new sealed bearings. because new cup and cone bearings for a bike hub are different in size, shape, and edges also, which will cause a big difference between old and new bearings, and you need to adjust new bearings in a right place within the hub, it is not an easy and repeatable step related to maintenance of bike, it requires proper skills, it would be better to solve this issue with the nearer mechanic bike shop.
All the derailleurs are not firm and have bending capacity, even the steel, and aluminum derailleur and hangers would bend and then regain their original shape, when the derailleur or hanger cause bending than the brake cable also cause a difference in its length which is installed within the rear derailleur because changing the shape and position of the derailleur would also differ length of the cable and further you need to adjust the length of the cable by screwing and unscrewing the bolt of the cable, even a small bending and deforming of the rear derailleur needs to adjust the length of the brake cable to create stress and force within the derailleur and hanger to avoid its rubbing and hitting with the spokes of the wheel.
The cable tensioning needs to be adjusted accurately, if the tensioning is too high it also causes bending of the hanger.
Installing Washers on Drive Side:
If the rear wheel is too close to the derailleur then you can install small washers compatible with the hub of the wheel before installing the cassette, these washers would keep the rear wheel and the derailleur at a noticeable distance from each other and prevents their rubbing and hitting.
Quick Release Issue:
If the QR skewer is not tightened fully within the hub and axle then it also gives rise to this problem, after maintaining the rear wheel or after uninstalling the rear wheel for puncturing or any other purpose, always tight the QR skewer when you have installed the wheel accurately.
Cross lacing Issue:
When the spokes are not tensioned correctly then at their crossing X points, both of the spokes would start rubbing with each other, as a result, these would constantly apply force towards the outward direction of the wheel and the crossing X region of the wheel comes nearer to the derailleur hanger, it only happens in the lowest and smallest gear cog.
Thin And Flexible Spokes Cause Hittng And Flexing:
There are many brands in spokes that are thick, thin, flexible, round, and aero shaped, but if the wheels are expensive and also your bike frame is modern and new with much heavier weight even the tires are also branded and much heavier than thin and cheap spokes would not tolerate this combination, you have to install new thick and expensive spokes to prevent bending and flexing and hitting with the rear derailleur.