Skip to content

Instantly share code, notes, and snippets.

@martink-io
Created October 9, 2018 14:43
Show Gist options
  • Save martink-io/ce81eeaab1694b6fd04583e0cceb36fe to your computer and use it in GitHub Desktop.
Save martink-io/ce81eeaab1694b6fd04583e0cceb36fe to your computer and use it in GitHub Desktop.
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware, compose} from 'redux';
import thunkMiddleware from 'redux-thunk';
import createLogger from 'redux-logger';
import reducer from './app/reducers';
import DashboardContainer from './app/containers/DashboardContainer';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu!!',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu!!',
});
// middleware that logs actions
// const loggerMiddleware = createLogger({ predicate: (getState, action) => __DEV__ });
function configureStore(initialState) {
const enhancer = compose(
applyMiddleware(
thunkMiddleware, // lets us dispatch() functions
),
);
return createStore(reducer, initialState, enhancer);
}
const store = configureStore({});
export default class App extends Component {
render() {
return (
<Provider store={store}>
<DashboardContainer/>
</Provider>
);
}
}
@martink-io
Copy link
Author

Could this be changed:

export default class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <DashboardContainer/>
      </Provider>
    );
  }
}

to this one?

const App = () => (
  <Provider store={store}>
     <DashboardContainer/>
  </Provider>
);

export default App;

Don't think the App needs to extend from Component as it's an entry point rather than an actual component. What do you think?

@khuramdogar
Copy link

Yes its is better this way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment