1

I have a react-native android application. My component in index.android.js is stateless so eslint is throwing the error "Component should be written as a pure function". If I make the component as pure function, how do i register the application or how should the instantiation be?

scn
  • 45
  • 2
  • 9
  • Possible duplicate of [ESLint - Component should be written as a pure function (react prefer/stateless function)](https://stackoverflow.com/questions/43378911/eslint-component-should-be-written-as-a-pure-function-react-prefer-stateless) – Nicolás Carrasco-Stevenson Mar 19 '18 at 11:42

1 Answers1

5

You can register the application even with a "pure function" This kind of code would work

 const App = () => {
  return (
    <MainApp />
  );
};

AppRegistry.registerComponent('myapp', () => App);

The "return" part can be deleted for a cleaner code:

const App = () => (
    <MainApp />
);


AppRegistry.registerComponent('myapp', () => App);
jpclair
  • 206
  • 1
  • 4