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.

custom widgets and React.memo

See original GitHub issue

Prerequisites

Description

Looks like the widgets props doesnt like react.memo Components for some reason.

Steps to Reproduce

Once wrapped in React.memo the component is not usable anymore as a form widget. this also impacts react-redux connect wrapper with produces a React.memo 😃

Here’s a repro : https://codesandbox.io/s/reactredux-connect-with-reactjsonschemaform-issue-8023j

Expected behavior

React memoified components should work 😃

Actual behavior

Throws with Unsupported widget definition: object

Version

1.6.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
RobUnderscorecommented, Aug 8, 2019

Simple workaround for now if you’re using redux connected components -

At the bottom of your custom widget component change:

export default connect(mapStateToProps)(ContractCategorySuperSelect)

to:

var ReduxWrapped = connect(mapStateToProps)(ContractCategorySuperSelect)

class CategorySelectWrapper extends Component {
  render () {
    return (
      <ReduxWrapped {...this.props} />
    )
  }
}

export default CategorySelectWrapper

Essentially just returning a standard react component with the redux connected component inside it.

0reactions
stale[bot]commented, Jun 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use React.memo() wisely
memo () does a shallow comparison of props and objects of props. To customize the props comparison you can use the second argument...
Read more >
How React.memo works? - Reintroducing React: V16 and ...
In this lesson, we'll discuss how React.memo works. ... All you do is wrap your functional component in the React.memo function call and...
Read more >
React.memo() vs. useMemo()
It offers React.memo() and useMemo() to implement memoization. ... you can also pass a custom comparison function as the second argument as shown...
Read more >
Optimize Components with React.memo, useMemo, and ...
Learn how to optimize components in React.memo, useMemo, and useCallback ... If this component renders and the value of widgets is the same, ......
Read more >
Use React Memo to Optimize Performance, Save
Optimize React Performance with React Memo and Save $$$ by Caching ... What is React.memo(); How to use React.memo(); Custom Prop Equality: ...
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