Skip to content

Commit 08caa67

Browse files
committed
Add default + check to allow props.value to be null | undefined
1 parent 1236d1f commit 08caa67

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/ReactCodeInput.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ReactCodeInput extends Component {
3333
super(props);
3434

3535
const { fields, forceUppercase } = props;
36-
let { value } = props;
36+
let value = props.value || '';
3737

3838
if (forceUppercase) {
3939
value = value.toUpperCase();
@@ -55,6 +55,10 @@ class ReactCodeInput extends Component {
5555
}
5656

5757
UNSAFE_componentWillReceiveProps(nextProps) {
58+
if (nextProps.value == null) {
59+
return;
60+
}
61+
5862
this.setState({
5963
value: nextProps.value,
6064
});

0 commit comments

Comments
 (0)