Want to build websites in no-time? Announcing the new Framer Beta.Learn more
Framer
  • Support
  • Using Framer
Want to build websites in no-time? Announcing the new Framer Beta.Learn more
Framer
  • Teams
  • Showcase
  • Developers
  • Resources
    • Tutorials
    • Examples
    • Components
    • Templates
    • Sessions
    • Support
    • Updates
  • Blog
  • Pricing
  • ···
    • Blog
    • Pricing
  • Support
  • Using Framer

Related Articles

  • Working with Arduino
  • Deprecated Code Component Width and Height Props
  • Differences between Preview and Export in code
  • Legacy Code
  • Code Editor

How to fix code component errors in the Insert Menu preview

In March 2022, we made changes how the Insert Menu shows components.


The change was needed to support NPM packages in Framer and also improved performance and reliability. Components are shown exactly the same in the preview as in the final result.


Some components might show errors due to incorrect API usage that is no longer supported. For example, props.children in a code component will no longer by an array, so should be accessed using React.Children:

// Before
const childrenCount = props.children.length
// After
const childrenCount = React.Children.count(props.children)
// Before
const firstChild = props.children[0]
// After
const childrenArray = React.Children.toArray(props.children)
const firstchild = childrenArray[0]
// OR, when only one child is expected
const firstChild = React.Children.only(props.children)
// Before
props.children.map(child => doSomething(child))
// After
React.Children.map(children, (child) => doSomething(child))
Helpful?Was this article helpful?

0

0

Framer

  • Teams
  • Pricing
  • Showcasenew
  • Blog
  • Developers
  • Updates

Platforms

  • Web
  • macOS
  • Windows
  • iOS
  • Android

Learn

  • Tutorials
  • Examples
  • Templates
  • Sessions

Resources

  • Components
  • Input Kit
  • State of Prototyping
  • Desktop Prototyping
  • Prototyping Tool
  • Mockup Tool
  • Wireframing Tool
  • UI/UX Design Tool
  • Graphic Design Tool
  • User Testing

About

  • Loupe
  • Community
  • Company
  • Careers
  • Legal

Support

  • Using Framer
  • Accounts
  • Contact

  • Twitter
  • Discord
  • Dribbble

Copyright © 2022 Framer B.V.

  • Security
  • Terms of Service
  • Privacy Statement