'number' fields received as strings

Detailed steps to reproduce the bug

We have a custom component with a subfield of type ‘list’, whose subfields are of type ‘number’, like…

{
  name: 'field_1',
  type: 'object',
  subFields: [
    {
      name: 'field_1_1',
      type: 'list',
      subFields: [
        {
          name: 'field_1_1_1',
          type: 'number',
          required: true,
        },
      ],
    },
    ...

Sometimes the numeric values entered into these inputs in the Builder editor are received by our app’s code as strings, and sometimes as numbers, like…

[{ field_1_1_1: '1126' }, { field_1_1_1: 1129 }]

I would expect these to be received as numbers, given the ‘number’ type. Even receiving them as strings would be reasonable, what’s confusing is to receive some as numbers and some as strings.

The app is using @builder.io/react 3.2.7 .

I checked for weird invisible characters, but can’t find them. Eventually, after deleting the input value in the Builder editor and entering it again several times , it was finally received as a number.

What’s happening here? Is there a bug in how ‘number’ inputs are handled?

Hey @xxavi , I’m having trouble replicating this issue because I’m consistently getting the value as a number, regardless of the different numbers I test. Could you please upgrade your React version to the latest one by running npm i @builder.io/react@latest on the terminal?
If this still doesn’t help, please share how you are receiving the number field type in your codebase.

Hi @sheema, thanks for your prompt reply.

Unfortunately, the problem persists after upgrading @builder.io/react to the latest version.

This is the code that reads the Builder inputs…

import builder from '@builder.io/react';

const builderJson = await builder
    .get(modelName, {
      userAttributes: {
        urlPath,
        ...userAttributes,
      },
      options,
      query,
    })
    .promise();

Then the ‘list’ field is read with something like this…

    builderJson.data.blocks[0].children[0].component.options.field_1.field_1_1