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.

Unable to use React.memo in React Native app

See original GitHub issue

I want to use React.memo for optimization in react native.

import React from "react";
import { View, Text } from "react-native";

const Memo = React.memo(function() {
  return (
    <View>
      <Text>Ok</Text>
    </View>
  );
});
class Demo extends React.Component {
  render() {
    return <Memo />;
  }
}

export default Demo;

It gives following error:

TypeError : undefined is not a function (evaluating render(nextProps)). This error is located at : in Demo(at renderApplication.js:34) in RCTView(at View.js:44 )

Can we use React.memo in react native?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:11

github_iconTop GitHub Comments

2reactions
JensonMirallescommented, May 28, 2019

For me the fix was instead of using

const Component =  React.memo((props) => { ... })

I used

const Component = (props) => {...}

export default React.memo(Component)

and it worked magically 🤣

1reaction
rsokzcommented, Nov 27, 2018

Getting the following error:

React.memo is not a function

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to use React.memo in React Native app - Stack Overflow
The "component" you are trying to memoize isn't a correct react component, it isn't being passed any props. The react memo HOC is...
Read more >
Unable to use React.memo in React Native app-Reactjs
The "component" you are trying to memoize isn't a correct react component, it isn't being passed any props. The react memo HOC is...
Read more >
Use React.memo() wisely
When a component is wrapped in React.memo() , React renders the component and memoizes the result. Before the next render, if the new...
Read more >
Higher-Order Components - React
In this document, we'll discuss why higher-order components are useful, and how to write your own. Use HOCs For Cross-Cutting Concerns. Note. We...
Read more >
Use React Memo to Optimize Performance, Save - Copycat
Optimize React Performance with React Memo and Save $$$ by Caching ... times especially recursive and mathematical functions in a React app.
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