0

following is the code to wrap stack navigator inside a redux provider

import React, { Component } from 'react';
import WelcomePage from './components/welcomePage';
import Register from './components/register';
import { StackNavigator } from 'react-navigation'
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';
import { Provider,connect } from 'react-redux';
import { store } from './store/store';

const mapStateToProps=state => {
    return state;
}
const mapDispatchToProps=dispatch => {
    return bindActionCreators(Actions, dispatch);
}

const handleSubmit=values=> {
  console.log(values);
}
const Navigationapp=StackNavigator({welcome:{screen:WelcomePage},register:{screen:props=><Register {...props} handleSubmit={handleSubmit}>}});
const Container = connect(mapStateToProps,mapDispatchToProps)(Navigationapp);
export default class App extends Component{
    render(){
        return (<Provider store={store}>
                     <Container/>
            </Provider>)
    }
};

but it shows following error

error: bundling failed: SyntaxError in C:\wamp64\www\rnativeTestProj\App.js: C:/wamp64/www/rnativeTestProj/App.js: Unexpected token, expected } (42:12)
  40 | const Container = connect(mapStateToProps,mapDispatchToProps)(Navigationapp);
  41 | export default class App extends Component{
> 42 |     render(){
     |             ^
  43 |         return (<Provider store={store}>
  44 |                      <Container/>
  45 |             </Provider>)
 BUNDLE  [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

what am I missing?is it a correct way to wrap stack navigator inside a redux-provider?

1 Answer 1

1
screen:props=><Register {...props} handleSubmit={handleSubmit}>

You lost a closing slash, it should be <Register />.

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.