小编Jey*_*raj的帖子

多用户登录身份验证| React Redux

我有一个具有多用户登录功能的应用程序。现在,我为登录功能创建了redux存储。如果用户登录,则根据其类型,它将重定向到特定的仪表板。如果学生用户登录,则他只能访问学生仪表板,而不能访问其他仪表板。其他也一样。但是,现在,如果有任何用户登录,他们便可以访问其他用户的仪表板。我如何防止他们仅使用仪表板。

更新了正确的代码

/***AppRouter***/
    import React, {Component} from 'react';
    import { BrowserRouter, Route, Switch } from 'react-router-dom';
    import StuDashboard from '../views/ed/dashboard/Dashboard.js';
    import AdminDashboard from '../views/biz/dashboard/Dashboard.js';
    import OrgDashboard from '../views/org/dashboard/Dashboard.js';
    import SupAdDashboard from '../views/me/dashboard/Dashboard.js';
    import UserLogin from '../views/loginUser/Login.js';
    import history from '../history/history.js';
    import { PrivateRoute } from './PrivateRoute.js';
    import NotFoundPage from '../views/NotFoundPage.js';
    import Authorization from './Authorization';



    class AppRouter extends Component {
      render () {
        return(

          <BrowserRouter history={history}>
            <Switch>
              <Route path="/" component={Landing} exact />
              <Route path="/confirmation" component={EmailCon}/>
              <PrivateRoute path="/student/dashboard" component={Authorization(StuDashboard),["Student"]}/>
              <PrivateRoute path="/admin/dashboard" component={Authorization(AdminDashboard),["Admin"}/> …
Run Code Online (Sandbox Code Playgroud)

reactjs redux react-redux

5
推荐指数
1
解决办法
361
查看次数

单击按钮打开 Google 地图 | Reactjs

我有一个地图组件,其中我使用Google-map-react库来显示谷歌地图中的位置。在该地图内,我有一个名为“在地图中查看”的按钮。所以,现在,如果用户单击该按钮。它应该将他们带到具有给定位置坐标的谷歌地图。请找到下面的代码并告诉我,我怎样才能实现这一目标

import React, { Component } from 'react';
import { withStyles } from '@material-ui/core/styles';
import styles from '../../../../../../assets/css/Me.style.js';
import GoogleMapReact from 'google-map-react';
import { Typography, Button } from '@material-ui/core';
import Marker from '@material-ui/icons/LocationOnOutlined'

class DetailsMap extends Component {
    static defaultProps = {
        center: { lat: 40.7446790, lng: -73.9485420 },
      };

     
  render() {
    const {classes} = this.props;
    return (
      <div className={classes.root}>
                
            <div className={classes.googleMap}>
                  <GoogleMapReact
                      zoom = {11}
                      onClick={this.onClick}
                      defaultCenter={ this.props.center }
                      >
                    <Marker
                      style={{color: '#ff7777'}}
                      lat={40.7473310}
                      lng={-73.8517440}
                    />
                    <div …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps reactjs google-maps-react

3
推荐指数
1
解决办法
1万
查看次数