question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Input type number is storing as string

See original GitHub issue

Redux@6.7.0

From the documentation, it says that inputs of type “number” will be stored as numbers. However, as you can see in my screenshot it is storing the values as a string. It would be awful if I have to parse them manually as this would be unnecessary looping.

Component

export const renderInput = ({ input, label, placeholder, type, meta: { touched, error } }) => (
    <Form.Field>
        <label>{label}</label>
        <input {...input} type={type} placeholder={placeholder} class={'' + (touched && error) ? 'error' : ''} />
    </Form.Field>
);

Field of type: number

<Field component={renderInput}
          name="baseValue" label="Default value"
           placeholder="0"
           type="number"
                        />

screen

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

89reactions
sanohincommented, May 29, 2017

You can use parse prop on Field.

<Field component={renderInput}
          parse={value => Number(value)}
          name="baseValue"
          label="Default value"
          placeholder="0"
          type="number"
/>
28reactions
alicerochemancommented, Nov 28, 2017

it would be great if the inputs of type ‘number’ remained numbers throughout the process! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML input type="number" still returning a string when ...
In other words, type="number" is a hint to implement client-side validation and appropriate GUI controls but the underlying element will still store strings...
Read more >
Why the number input is the worst input - Stack Overflow Blog
We do have an input that's labeled as a number, but when you add it to your form, it actually renders as <input...
Read more >
input type=number – number input control (NEW) - HTML5
The input element with a type attribute whose value is " number " represents a precise control for setting the element's value to...
Read more >
<input type="number"> - HTML: HyperText Markup Language
<input> elements of type number are used to let the user enter a number. They include built-in validation to reject non-numerical entries.
Read more >
JS. How do you add input type " number" as a ... - Sololearn
JS. How do you add input type " number" as a number _ and avoid strings? · Getting NaN as the output IS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found