reactjs-flux

How to handle one-to-many relationships in Flux stores

一个人想着一个人 提交于 2019-12-05 15:56:59
问题 I'm just starting to use flux (with redux for now) and am wondering how relationships are supposed to be handled. For an example we can use Trello that has boards with columns that contains cards. One approach would be to have one store/reducer for boards and have all the data in it there but that means some very fat stores since they would have to contain all the actions for columns and cards as well. Another approach i've seen is separating nested resources into for example BoardStore,

React: input validation

核能气质少年 提交于 2019-12-05 10:45:15
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 could not find the best practices everyone tries to invent something own and as a result you need to

jQuery UI Sortable with React.js buggy

こ雲淡風輕ζ 提交于 2019-12-05 10:10:17
I have a sortable list in React which is powered by jQuery UI. When I drag and drop an item in the list, I want to update the array so that the new order of the list is stored there. Then re-render the page with the updated array. i.e. this.setState({data: _todoList}); Currently, when you drag and drop an item, jQuery UI DnD works, but the position of the item in the UI does not change, even though the page re-renders with the updated array. i.e. in the UI, the item reverts to where it used to be in the list, even though the array that defines its placement has updated successfully. If you

How to handle non-view-altering actions in Flux & React.js

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 06:21:53
问题 In Flux every action should be handled by the dispatcher. What about an action that doesn't alter the view or the markup, such as "scroll this element into view"? What is the "Flux-way" of handling such a scenario? To by-pass the dispatcher? Or to handle it in the dispatcher without involving the stores or the components? 回答1: Flux is really more about application state management, and is not at all about the details of what components are rendered in the view. That's the domain of React.

Why should addChangeListener be in componentDidMount instead of componentWillMount?

百般思念 提交于 2019-12-05 04:12:19
I saw this line as an answer to another question on here: "componentWillMount should be componentDidMount, or else you'll leak event emitters in node." and I don't really understand it. Can someone explain with more detail? More info: Building a react application with flux, as part of the initial render, a child component computes some data. Ideally, after this data is computed, I would like to call an action that updates the store's state with a portion of this new data. Normally, updating the store's state emits a change event that causes a re-render. However, because the change listener isn

Update redux state with an input

走远了吗. 提交于 2019-12-05 02:24:27
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'; import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; import {search} from

Cannot read property '__reactAutoBindMap' of undefined

99封情书 提交于 2019-12-05 02:01:11
For the last week now I've been completely at a loss for how to set up server side rendering with React. This is a new project but it's an express server and I'm attempting to render just a super simple hello world react app which uses react-router-component.. I think the best way for me to get some help is to share the code I have right now and I'm hoping somebody can please tell me what I'm doing wrong! I've followed tutorial after tutorial and tried all sorts of different things but I keep getting error after error! This is my app.js for the express server, the relevant code is the * route

How to redirect after success from ajax call using React-router-component?

为君一笑 提交于 2019-12-04 19:00:19
问题 I am building a application using Facebook flux architecture of React JS . I have build the basic part of app where I have a login form. I am fetching the the result from node server to validate user at the store, I am getting the result from server, Now I got stuck that how can I redirect the user to home page after success. I have read about the react router component and I am able to redirect at the client side but not able to redirect at the time of fetching result from ajax in Store.

Should the action or store be responsible for transforming data when using React + Flux?

别说谁变了你拦得住时间么 提交于 2019-12-04 14:42:59
When using React and Flux, it's standard practice to make API calls from actions, and then store the resulting data in a Store class. But who should be responsible for transforming that data after it's been stored? Example: I've got an EntryStore that keeps hold of objects representing shopping list items. I have a number of filters that I can apply to them (e.g "show only dairy "). I currently have this working by calling EntryActions.filterEntries('dairy') , which the dispatcher then passes to EntryStore where a _filterEntries(tag) method transforms the EntryStore._entries array. Is this

How to wait to render view in react.js until $.get() is complete?

北慕城南 提交于 2019-12-04 13:24:19
Hello I'm writing a chat client in reactjs and want to render my components with data retrieved from a REST call. However, my component is rendered before the REST request returns with data; this causes errors as I am calling this.props within my children components. var MainChat = React.createClass({ getInitialData: function(){ var c = [] $.get("http://127.0.0.1:8888/test/sampledata.php?user=123", function(data, status) { console.log("Data: "+ data+ "\nStatus: " + status); c = data }) }, getInitialState: function() { return { chatId : "", chats : this.getInitialData(), //chats: this.props