Skip to content

Conversation

Copy link

Copilot AI commented Jul 6, 2025

Starting from s-forms version 0.8.1-alpha-0838f82.0, the library requires the React IntlProvider to be in the component ancestry and expects the intl object to have methods like formatMessage, formatDate, etc. The previous implementation was passing a simple object structure through options, which caused the error:

[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.

Root Cause

  1. MainView was passing state.intl (from Redux) instead of the actual React Intl object from injectIntl
  2. RecordForm was using I18nStore.getIntl() which returned the wrong intl object structure
  3. The newer s-forms version expects a full React Intl object with all formatting methods

Changes Made

MainView.jsx

  • Removed intl: state.intl from mapStateToProps so that this.props.intl now comes from the injectIntl HOC
  • This provides the correct React Intl object with all required methods

RecordForm.jsx

  • Changed from intl: I18nStore.getIntl() to intl: this.props.intl to pass the actual React Intl object to SForms
  • Added intl: PropTypes.object to properly type the intl prop

Before vs After

Before: s-forms received a simple object like:

{
  locale: 'en',
  messages: { 'wizard.next': 'Next', ... }
}

After: s-forms receives a full React Intl object with:

{
  locale: 'en',
  messages: { 'wizard.next': 'Next', ... },
  formatMessage: Function,
  formatDate: Function,
  formatTime: Function,
  // ... other React Intl methods
}

This fix ensures that SForms receives the proper React Intl object while maintaining backward compatibility with existing functionality.

Fixes #277.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • kbss.felk.cvut.cz
    • Triggering command: npm install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@palagdan palagdan closed this Jul 6, 2025
Copilot AI changed the title [WIP] SForms error: Could not find required intl object. <IntlProvider> needs to exist in the component ancestry. Fix SForms IntlProvider error by using React Intl context directly Jul 6, 2025
Copilot AI requested a review from palagdan July 6, 2025 20:55
Copilot finished work on behalf of palagdan July 6, 2025 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SForms error: Could not find required intl object. <IntlProvider> needs to exist in the component ancestry.

2 participants