You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to create a component named PrivateScene that would verify by onEnter property if this scene is allowed for guests... with this custom component would become easier to call this scenes on my Routes file.
Instead of <Scene key="something" component={Component} onEnter={this.onEnter} /> i would have <PrivateScene key="something" component={Component} />.
Less code and easier to do changes.
Actual behaviour
The onEnter method don't work unless i call like this <Scene key="something" component={Component} onEnter={this.onEnter} />, but in my PrivateScene component, i already have a Scene component calling the onEnter.
Steps to reproduce
PrivateScene.js
import React, { Component } from 'react';
import { Scene } from 'react-native-router-flux';
class PrivateScene extends Component {
handleEnter = () => {
console.log('Check here if the user is authenticated');
};
render() {
return <Scene {...this.props} onEnter={this.handleEnter} />;
}
}
export default PrivateScene;
Routes.js
import React, { Component } from 'react';
import { Router, Stack, Scene } from 'react-native-router-flux';
import * as Pages from 'pages';
import { PrivateScene } from './components';
class Routes extends Component {
state = {};
render() {
return (
<Router>
<Stack key="root">
<Scene key="login" component={Pages.Auth.Login} initial />
<PrivateScene key="welcome" component={Pages.Welcome} />
</Stack>
</Router>
);
}
}
export default Routes;
The onEnter only works if i handle it in Routes.js component.
The text was updated successfully, but these errors were encountered:
I believe this is a duplicated of #3208. Not sure if this is supported right now - the solution we found out was a HoC to provide it, like I wrote here: #3208 (comment). In case you want to contribute providing this support, PRs are welcome.
I couldn't handle onEnter with your solution
I want to create PrivateSeen if the user didn't authorize, it redirects them to login scene
can you give me an example please?
Version
Expected behaviour
I would like to create a component named PrivateScene that would verify by onEnter property if this scene is allowed for guests... with this custom component would become easier to call this scenes on my Routes file.
Instead of
<Scene key="something" component={Component} onEnter={this.onEnter} />
i would have<PrivateScene key="something" component={Component} />
.Less code and easier to do changes.
Actual behaviour
The onEnter method don't work unless i call like this
<Scene key="something" component={Component} onEnter={this.onEnter} />
, but in my PrivateScene component, i already have a Scene component calling the onEnter.Steps to reproduce
PrivateScene.js
Routes.js
The onEnter only works if i handle it in Routes.js component.
The text was updated successfully, but these errors were encountered: