From 6ee3d77e556ab42b332911fb4e630b9d0dcd8157 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 9 Jun 2020 18:26:49 -0500 Subject: [PATCH] Forms: set id in state, fixes #178 --- app/soapbox/features/forms/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/soapbox/features/forms/index.js b/app/soapbox/features/forms/index.js index c51d14af7..75feac6d4 100644 --- a/app/soapbox/features/forms/index.js +++ b/app/soapbox/features/forms/index.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import ImmutablePureComponent from 'react-immutable-pure-component'; import PropTypes from 'prop-types'; import classNames from 'classnames'; @@ -37,7 +37,7 @@ InputContainer.propTypes = { }; export const LabelInputContainer = ({ label, children, ...props }) => { - const id = uuidv4(); + const [id] = useState(uuidv4()); const childrenWithProps = React.Children.map(children, child => ( React.cloneElement(child, { id: id, key: id }) )); @@ -168,9 +168,13 @@ export class RadioItem extends ImmutablePureComponent { checked: false, } + state = { + id: uuidv4(), + } + render() { const { label, hint, dispatch, ...props } = this.props; - const id = uuidv4(); + const { id } = this.state; return (