'Attribute Not Updating with NumberControl
I have a Attribute which is designed to be controlled by a Number Control Attribute
<NumberControl
label={ __( 'SM' ) }
onChange={ ( value ) => setAttributes( { SM: value } ) }
value={ attributes.SM }
help={ __( 'Response SM Setting for Column' ) }
min={ 0 }
max={ 12 }
/>
Is there something I am doing wrong with this? I can't seem to find a good solution whatsoever
Solution 1:[1]
You'll need to add parseInt to the value while updating the attributes. Check it here I have fixed the issue.
<NumberControl
label={ __( 'SM' ) }
onChange={ ( value ) => setAttributes( { SM: parseInt(value) } ) }
value={ attributes.SM }
help={ __( 'Response SM Setting for Column' ) }
min={ 0 }
max={ 12 }
/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Harit Panchal |
