1

Using react 16.6 I am trying to use memo with stateless component but I get an error.

Error

react-dom.development.js:57 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Code:

const MyComponent = () => (
  <React.Fragment>
    TEST
  </React.Fragment>
);

export default React.memo(MyComponent);
2
  • I think you need curly brackets { } on the right hand side of the arrow function. Commented Oct 31, 2018 at 15:09
  • had to disable prettifier to test that, didn't work ( Commented Oct 31, 2018 at 15:13

1 Answer 1

6

You should update react-dom to the ^16.6.0 version, too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.