小编Rac*_*mir的帖子

React-Router v4 + Redux-Saga导航

我正在尝试在成功的身份验证过程(登录/注册后)之后移动用户,但是看起来我在互联网上找到的每个解决方案-stackoverflow / github问题/介质等-不起作用!

请在下面找到我的代码。

import { call, put, takeLatest } from 'redux-saga/effects'
import { push } from 'react-router-redux'

import { USER_LOGIN_SUCCEEDED, USER_LOGIN_FAILED, USER_LOGIN_REQUESTED } from '../actions/types'

import { login } from '../api'

function * loginUser (action) {
  try {
    const token = yield call(login, action.payload.email, action.payload.password)
    yield put({type: USER_LOGIN_SUCCEEDED, token: token})
    yield put(push('/dashboard'))
  } catch (error) {
    yield put({type: USER_LOGIN_FAILED, error: error.message})
  }
}

function * loginSaga () {
  yield takeLatest(USER_LOGIN_REQUESTED, loginUser)
}

export default loginSaga
Run Code Online (Sandbox Code Playgroud)

not sure if its …

reactjs redux-saga react-redux react-router-redux

7
推荐指数
2
解决办法
4186
查看次数

使用 Express 服务 REACT 组件不起作用(仅呈现 html 文件)

你好,我正在学习 MERN 堆栈,我在服务我的 React 组件时遇到问题,这是 server.js 代码

const path = require('path')
const fs = require('fs')
const express = require('express')
const app = express()

app.set('view engine', 'html')
app.engine('html', function (path, options, callback) {
  fs.readFile(path, 'utf-B', callback)
})

const cors = require('cors')
app.use(cors({
  'origin': '*',
  'methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
  'preflightContinue': false,
  'optionsSuccessStatus': 204
}))

const bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: true}))

app.use(express.static(path.join(__dirname, '/build')))

app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, '/build'), 'index.html')
  res.end()
})

app.use('/*', (req, res) => res.status(404).send())

const isDev = true
app.use((err, req, …
Run Code Online (Sandbox Code Playgroud)

express reactjs webpack mern

6
推荐指数
1
解决办法
2991
查看次数