From d7d41b171760a0b16905c6359110c977555ded26 Mon Sep 17 00:00:00 2001 From: HIMANSHU Date: Tue, 16 Apr 2024 11:52:28 +0530 Subject: [PATCH] feat: Refactor example screen --- app/scenes/ExampleScreen/index.js | 56 +++++++++---------- app/scenes/ExampleScreen/saga.js | 2 +- app/scenes/ExampleScreen/tests/index.test.js | 12 ++-- .../ExampleScreen/tests/reducer.test.js | 23 ++++---- .../ExampleScreen/tests/selectors.test.js | 31 +++++----- 5 files changed, 61 insertions(+), 63 deletions(-) diff --git a/app/scenes/ExampleScreen/index.js b/app/scenes/ExampleScreen/index.js index 1d7df58..3b273c1 100644 --- a/app/scenes/ExampleScreen/index.js +++ b/app/scenes/ExampleScreen/index.js @@ -1,4 +1,3 @@ -import React from 'react'; import { Button, Platform, View, ActivityIndicator } from 'react-native'; import { connect } from 'react-redux'; import { compose } from 'redux'; @@ -6,6 +5,7 @@ import { PropTypes } from 'prop-types'; import styled from 'styled-components/native'; import { createStructuredSelector } from 'reselect'; import { injectIntl } from 'react-intl'; +import React, { useEffect } from 'react'; import AppContainer from '@atoms/Container'; import SimpsonsLoveWednesday from '@organisms/SimpsonsLoveWednesday'; @@ -44,36 +44,32 @@ const instructions = Platform.select({ 'Double tap R on your keyboard to reload,\nShake or press menu button for dev menu.' }); -class ExampleScreen extends React.Component { - componentDidMount() { - this.requestFetchUser()(); - } - - requestFetchUser = () => () => { - this.props.fetchUser(); +const ExampleScreen = props => { + const requestFetchUser = () => { + props.fetchUser(); }; - - render() { - return ( - - {this.props.userIsLoading ? ( - - ) : ( - - - -