reactjs-flux

Update redux state with an input

牧云@^-^@ 提交于 2020-01-13 08:21:05
问题 How can I update redux's state from a text input? I'm trying to do a very simple "Hello World" with a text input. When someone types into the text input, it should update my store's "searchTerm" value. I can't figure out these things: 1. How can I get and pass the input's value into it's "onChange" handler? 2. The "search" action seems to be called correctly, but my reducer function is never used (no console.log). SearchForm.js (component) import React, {Component, PropTypes} from 'react';

Dispatching cascading/dependent async requests in Flux/React

ぐ巨炮叔叔 提交于 2020-01-13 05:13:13
问题 I know this question has been asked more times in different flavours, but I didn’t find the "right" answer yet (maybe there just isn't one), so I’m looking for the "most Flux" one. Simple example: two components - LoginForm and Information user has to provide his/hers login information, submit the form and only after that he/she has right to "ask" for the information (this should be done automatically after login) Project structure along these lines: + actions |-- LoginAction |-- InfoAction +

React: input validation

送分小仙女□ 提交于 2020-01-02 04:15:08
问题 I recently started working with React and I faced the problem with inputs validation. For example, it simply implemented in another framework as Angular.js via directives. After some researching I found newforms library, looks like the best solution from the box on current moment. But it's pretty heavy and not sure that it's currently supported (last update 7 months ago). Another approach is sending events from parent form to its children inputs, and calling validation method on each. But I

Is triggering an action in the store bad practice?

混江龙づ霸主 提交于 2020-01-01 03:09:08
问题 Stores are supposed to handle the events triggered by actions and emit the change to the listening view controllers. Is it ok for them to trigger actions as well, for example in the callback of a request or directly in the store's registered callback. For example: AppDispatcher.register(function(payload) { switch(payload.action.actionType) { case Constants.PAGE_CHANGED: ActionCreator.fetchNewData(); break; case Constants.FETCH_DATA: // save data Store.emitChange(); break; } }); Is code like

Dispatching further actions when handling actions

时光毁灭记忆、已成空白 提交于 2020-01-01 02:29:11
问题 I have a scenario where I feel like I need to dispatch an action in response to another action, and I don't know the best way to sort it out. An action is dispatched in response to an HTTP response, something like: type: 'auth' data: { username: 'tom' } Because that response was successful, I want to dispatch an action to send the user to the homepage: type: 'navigate' date: { where: 'home' } This seems like a sensible flow to me: this thing happened, so now I want this thing to happen.

flux multiple store instances

可紊 提交于 2019-12-30 02:08:17
问题 In a flux application where data is divided into buckets by owner id, should we use one store which internally separates the data into buckets, or one store instance per bucket? For instance, we have an application user who is a coach for multiple athletes. Each coached athlete has zero or more workouts, and the coach can view one or more athletes' workouts at the same time. We could have one workout store for all athletes; the store has to ensure that all data is separated into athlete

Is there a convention for Flux messages sent via the Dispatcher?

只愿长相守 提交于 2019-12-25 10:19:42
问题 I'm building my first React front end and see a number of conventions for messages sent via the Dispatcher. e.g. { type: ActionTypes.RECEIVE_RAW_MESSAGES, rawMessages: rawMessages } https://github.com/facebook/flux/blob/master/examples/flux-chat/js/actions/ChatServerActionCreators.js#L21 and { source: 'VIEW_ACTION', action: action } http://facebook.github.io/react/blog/2014/09/24/testing-flux-applications.html#putting-it-all-together What is the best message format to use & why? 回答1: The

Calling other action on the basis of results of other action in React JS

人走茶凉 提交于 2019-12-24 13:26:12
问题 I have a PageComponent it contains following react components :- Add item form. [FormComponent] Paginated List of items. [UserListComponent] When user clicks on Add Item in Add item form. A action is called using ActionCreator and then it calls the API server along with Success/Failure callback. //Calling action action creator from the component ActionCreator.addUser({email:email, dept_code:dept}); //Action Creator calling action using dispatcher. addUser: function(userObj){ ApiClient.addUser

Where do model helpers belong in React/Flux?

可紊 提交于 2019-12-24 03:42:28
问题 While attempting to wrap my brain around React and Flux, I am having a hard time deciding where it makes sense to put what I'd call "model helper" methods. For example, given a situation where there is a "Person" entity contained within a Store, and given that Person has a "first name" and a "last name", where would the most logical place to put a "full name" helper method that simply concatenates the two together? My gut says that it would be best to have "full name" be within the Store, but

React component this.props is always empty

六月ゝ 毕业季﹏ 提交于 2019-12-24 03:09:10
问题 I've followed a couple of examples in an attempt to get access to a parameter from a Route in the React component that handles it. However the result of console.log on this.props from inside the render or componentDidMount is always {} when I'd expect it to contain the gameId from the gamesView route. client.js which starts the Router: // HTML5 History API fix for local if (config.environment === 'dev') { var router = Router.create({ routes: routes }); } else { var router = Router.create({