Hi i need Help i have created an index page which checks if user is logged in or not and redirect accordingly and data is pass to that component via createContainer everything was working fine but now after logging in i have open Router Page and Redirecting from there All the components are routing properly except the components with withTracker i am again pushed to default initial screen
Walkthrough->
1.)Login Screen
2.)Shows Timesheets(initial in router)
3.)click Leaves->Apply Leave
4.)Tried opening Apply leave
5.)Opens For a second and then Back to initial Page(Timesheets)
index.js
`const myApp = (props) => {
const { status, user, loggingIn } = props;
if (status.connected === false || loggingIn) {
// return <Loading />;
return <RouterStack />
} else if (user !== null) {
// return <Home />
return <RouterStack />
}
return <Login />
};
myApp.propTypes = {
status: PropTypes.object,
user: PropTypes.object,
loggingIn: PropTypes.bool,
};
export default createContainer(() => {
return {
status: Meteor.status(),
user: Meteor.user(),
loggingIn: Meteor.loggingIn(),
};
}, myApp);
`
Router.js
`
export default class App extends Component {
constructor(props) {
super(props)
}
render() {
return (
<Router getSceneStyle={() => styles.sceneStyle}>
<Scene key="root">
<Scene key="Timesheets" component={Timesheets} title="Timesheets" initial />
<Scene key="applyLeave" component={ApplyLeave} title="Apply Leave" />
<Scene key="Login" component={Login} title="Login" />
<Scene key="Leaves" component={Leaves} title="Leave" />
<Scene key="ViewLeave" component={LeaveHistory} title="Leaves History"/>
<Scene key="Profile" component={Profile} title="Profile" />
</Scene>
</Router>
)
}
}
`
ApplyLeave.js
`class ApplyLeave extends Component {
render(){
return <View><Text></Text></View> //just for Demo
}
}
export default withTracker(params => {
if (Meteor.user() != null) {
const employeeId = Meteor.user();
const leaves = Meteor.subscribe('leaves', employeeId);
const entitlements=Meteor.subscribe('entitlements',employeeId);
return {
myLeavesReady: leaves.ready(),
myEntitlements: entitlements.ready()
};
}
return {}
})(ApplyLeave);
`