Forms: set id in state, fixes #178

stable/1.0.x
Alex Gleason 2020-06-09 18:26:49 -05:00
rodzic bf55593513
commit 6ee3d77e55
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
import React from 'react'; import React, { useState } from 'react';
import ImmutablePureComponent from 'react-immutable-pure-component'; import ImmutablePureComponent from 'react-immutable-pure-component';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import classNames from 'classnames'; import classNames from 'classnames';
@ -37,7 +37,7 @@ InputContainer.propTypes = {
}; };
export const LabelInputContainer = ({ label, children, ...props }) => { export const LabelInputContainer = ({ label, children, ...props }) => {
const id = uuidv4(); const [id] = useState(uuidv4());
const childrenWithProps = React.Children.map(children, child => ( const childrenWithProps = React.Children.map(children, child => (
React.cloneElement(child, { id: id, key: id }) React.cloneElement(child, { id: id, key: id })
)); ));
@ -168,9 +168,13 @@ export class RadioItem extends ImmutablePureComponent {
checked: false, checked: false,
} }
state = {
id: uuidv4(),
}
render() { render() {
const { label, hint, dispatch, ...props } = this.props; const { label, hint, dispatch, ...props } = this.props;
const id = uuidv4(); const { id } = this.state;
return ( return (
<li className='radio'> <li className='radio'>