"National Labor Relations Act (NLRA) was amended by the Taft-Hartley Act in 1947, allowing individual states to supersede the union security provisions of the NLRA by enacting laws that prohibit union security agreements. These state laws are known as right to work (RTW) laws."
The legislative history is described in a Congressional Research Service report, Right to Work Laws: Legislative Background and Empirical Research by Benjamin Collins.