Skip to content

Instantly share code, notes, and snippets.

@Kolenov
Last active September 10, 2021 12:33
Show Gist options
  • Save Kolenov/c763a9d0bc9fc3359a90c97ceb563aac to your computer and use it in GitHub Desktop.
Save Kolenov/c763a9d0bc9fc3359a90c97ceb563aac to your computer and use it in GitHub Desktop.
React, MobX and Ramda conditional rendering
const enhance = R.compose(
inject('store'),
observer
)
const AuthContent = (props => R.cond([
[R.equals(Page.signin), () => <SignIn {...props}/>],
[R.equals(Page.signup), () => <SignUp {...props}/>],
[R.equals(Page.confirm), () => <PasswordResetConfirm {...props}/>],
[R.equals(Page.forgot), () => <PasswordReset {...props}/>],
[R.equals(Page.edit), () => <PasswordEdit {...props}/>],
[R.equals(Page.setPassword), () => <PasswordSet {...props}/>]
])(R.path(['uiStateStore', 'currentView'], props.store)))
export default enhance(AuthContent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment