Skip to content

Passing react element as label causes "Converting circular structure to JSON" error. #82

Description

@tappleby

This is similar to #33, I am trying to use react-intl components for translating the form labels, but the issue will happen for any react element:

<Input
  name="testInput"
  label={
    <FormattedMessage
      id="testInput.label"
      defaultMessage="Test label"
    />
  }
/>

This issue is caused by the JSON.stringify(label) in the component.getId mixin

I have a few ideas around fixing this, but not sure the best approach to take:

  1. Only try and hash label if React.isValidElement returns false
  2. Dont include the label when generating the id.
  3. Require input label prop type to be string, use alternate method to get translation.

It would be nice if we could generate a unique id for each Formsy.Form component, then hashing the label wouldnt be necessary. Was thinking we could maybe opt into this using the parent context mixin.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions