Some states do not have laws to prevent the perpetrators of rape from seeking custody and visitation of children conceived during that act.
No laws restrict rape victims from seeking child support from their rapists.
A meme long circulated via social media holds that in 31 states it is legal for a rapist to sue his victim for custody of a child conceived during a sexual assault, but in no states do rape victims have legal standing to sue their attackers for child support:
The latter claim was the more straightforward, asserting that in all 50 states a victim of rape cannot sue her rapist for child support. We were unable to find any law expressly prohibiting such an action in any state, although objections to the structure and efficacy of mandated child support in rape cases remains controversial. For example, a June 2015 article reported on a case involving a teenaged rape victim who was compelled to seek support in family court, effectively commanding her to maintain a relationship with her attacker:
[Lawyer Wendy] Murphy has been representing a victim who was  when she was raped by a 20-year-old, who was then convicted. The convicted assailant was then remanded to family court to pay child support for the baby that resulted from the rape, a court decision that Murphy is still fighting in appellate court in Massachusetts.
"It's an unconscionable thing to have your own government, in the name of justice, force you into an 18-year relationship with your attacker in family court," Murphy said of her client's experience.
She also said convicted rapists should be forced to pay restitution in criminal court, not child support in family court.
A 2013 legal paper noted that "victims of sexual violence hide from their abusers, and child support orders and proceedings [frequently triggered by requests for social assistance] necessarily renew contact between rapist and victim." The paper further explained that "a dangerous absent parent may react to the child support notification by renewed violence or by asserting rights to custody and visitation, which would seriously harm the mother and child."
In a preface, the paper noted that conditions differ from state to state with respect to the burden of proof placed upon rape victims in cases involving child support due to various requirements with respect to social programs and assistance (known sometimes as paternity "cooperation requirements"):
All states accept official documentation, often in the form of records from birth certificates and documentation from medical professionals or law enforcement. The majority of states provide that sworn statements of third parties with knowledge of the circumstances leading to good cause may substantiate the claim. A minority of states, however, articulate polarized approaches, outlining either a more achievable “permissive” approach, or requiring more demanding “restrictive” standards. The minority permissive approach allows for both third–party statements and applicant corroboration, while the minority restrictive approach will not accept anything other than official documentation. This Note argues that states must craft evidentiary requirements that are compatible with victim behavior following sexual assault to properly protect rape victims seeking welfare benefits from the danger of continued contact with their rapist through child support enforcement. The majority and minority restrictive approaches are too limited, as they require the rape victim to have reported or disclosed her rape in order to receive benefits, despite the realities of victim behavior.
No aspect of that preface suggested that victims of rape "cannot" seek child support, only that laws in some states are structured in a manner that effectively discourage or present difficult-to-surmount barriers to such action.
The primary claim, that 31 states allow a rapist to sue a victim for custody and visitation rights, is far murkier. Unrelated actions decided upon by the Supreme Court in the mid-1990s have upheld state authority over federal authority in cases pertaining to rape.
A possible source for the "31 states" assertion appears to be a 31 August 2012 item published by The Atlantic titled "31 States Allow Rapists Custody and Visitation Rights." That piece referenced a 2010 law journal article about what might be called a legal loophole, while observing that between 2010 and 2012, several states had amended their laws:
In a paper published in the The Georgetown Law Journal in 2010 — when the number of states without such laws [specific to rape and child custody] were even greater — [lawyer Shauna] Prewitt argued that the absence "stems from the images and other societal rhetoric that depict the prototypical raped woman as hating her unborn child and as viewing her rape pregnancy as continuing her rape trauma." In her CNN piece, she blames it on "ignorance": Some believe that women don't raise children conceived from rape, others can't fathom a rapist wanting parental rights.
That 2012 reporting hinted at one factor pertaining to the claim's accuracy: the passage of time. In 2016, CNN reported that additional states had implemented legislation to address circumstances where the law might not sufficiently protect a victim of rape from being forced to interact with the attacker:
Seven states don't have any laws preventing a rapist from claiming parental rights, but that's not to say that these states are oblivious to the issue. Maryland, for one, has been working for years to pass a law that would allow a rape victim to terminate her attacker's parental rights.
Forty-three other states and the District of Columbia have legislation that offers at least some protection to prevent rape victims from facing their attackers over parental rights; eight of those laws were just adopted in 2016.
But these legislative protections vary greatly. In 20 states and D.C., a rape conviction is required before a victim can request termination of parental rights.
CNN's coverage also alluded to another difficulty in precisely determining a rape victim's vulnerability to custody challenges, namely that a rape conviction is necessary in order for the victim to request her attacker's parental rights be severed. The piece observed that the requirement is problematic, as "the majority of sexual assaults don't even make it to prosecution," according to Bureau of Justice statistics:
That means in nearly half the states that have legislation meant to prevent rapists from claiming parental rights, a victim is still vulnerable to having to face her attacker if there wasn't a conviction in her case -- and that's if she reported it and if it was prosecuted.
The article was footnoted with a state-by-state guide to rights granted to both victims and their attackers, laws which very rarely appeared to resemble one another. For instance, the burden of proof in the state of Michigan was "clear and convincing evidence that a child was conceived through sexual assault," but the alphabetically-adjacent state of Minnesota "[did] not currently have any legislation protecting mothers who conceived their child through rape from facing their attackers over custody and visitation rights." Whether those laws have changed since 2016 is unclear, and the details of such laws vary to a point where comparison between them is effectively impossible.
The meme's fundamental premise (that 31 states allow a rapist to sue a victim for custody and visitation rights) is somewhat flawed in the sense that we could not find any state with a law on its books expressly permitting the perpetrator of a rape, convicted or not, to subsequently re-traumatize his victim using the court as a weapon (as opposed to states that lack laws expressly prohibiting such conduct). Determining a specific number of states in which rapists are not prevented from seeking access to the children of their victims is virtually impossible due not only to rapidly changing laws, but also to broad differences in how such a legal barriers might be enacted in any given state.