reactjs-flux

POST muiltiple multipart file with React

不羁的心 提交于 2019-12-12 04:37:18
问题 I put this questions in reference POST a file with React.js I would like now to send a list of files to the endpoint. My input component: <input onChange={(e) => Actions.uploadXLS(e.target.files)} multiple type="file" name="xlsz" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" style={{ display: 'none' }}/> The action handler: uploadXLS(files) { let i = 0; const data = new FormData(); for ( i = 0; i < files.length; i++ ) { data.append( 'file' , files[i]); } console

React-Redux - Reuseable Container/Connector

此生再无相见时 提交于 2019-12-12 03:25:44
问题 I am completely lost on the react-redux container (ie connector) concept as it is not doing what I anticipated. My issue is straight forward, and to me reasonable, yet I cannot find a well written example of how to accomplish it. Let us say we have a react component that connects to a store that has product context, and we will call this component ProductContext . Furthermore, let's say we want to reuse ProductContext liberally throughout the app so as to avoid the boilerplate code of

How should I be recreating a stateful child component in a parent's render method?

纵饮孤独 提交于 2019-12-11 13:17:59
问题 Facebook says that I should not keep a React component in its parent's state. Instead I should be recreating the child in render method each time it is run. What Shouldn't Go in State? React components: Build them in render() based on underlying props and state. Now my question is: How can I do that? Is it even possible? Isn't the state lost if I recreate a child component from scratch? The only way I can think of that this scenario will work in, is that there's only one state object and it

ReactJS: Check props and state on shouldComponentUpdate

时光总嘲笑我的痴心妄想 提交于 2019-12-10 15:22:30
问题 I want to check all properties and state if they are changed, return true if any changed and make a base component for all my root components. I'm wondering if it won't be the best practice and make my components slow. Also, what I did always returns true: shouldComponentUpdate: function(newProps, newState) { if (newState == this.state && this.props == newProps) { console.log('false'); return false; } console.log('true'); return true; }, Is there anything wrong with my code? Should I check

how to remove / unmount nested react components

a 夏天 提交于 2019-12-10 14:33:29
问题 I'd like to unmount a single react component, which belongs to a parent component containing three components total. The parent component has this render function: render: function () { return ( <div className={classes}> <Navbar ref="navbar"/> <Home ref="home"/> <Footer ref="footer"/> </div> ), handleNavbarClick: function () { // remove Home } if a user then clicks on a link in the navbar and I want to unmount the Home component, how would I do that? it seems like my only option is to do

Using React's immutable helper with Immutable.js

丶灬走出姿态 提交于 2019-12-10 13:15:14
问题 I'm working on a flux application and am considering adopting immutable.js to maintain state. I saw that react supplies its own helper for updating immutable objects (http://facebook.github.io/react/docs/update.html), but couldn't tell how it was much different from immutable's own setIn and updateIn methods (i.e, i can already compare objects with === to se if they changes with setIn). Is there a reason to use the react helper with immutable.js? Is it just syntactic sugar? TL;DR is: var map

React Flux: what's the point of actions?

浪子不回头ぞ 提交于 2019-12-10 11:24:31
问题 In Flux , what is the point of using actions , instead of just letting the component publish directly to the dispatcher ? What is it that I can't do without actions ? 回答1: The action creators decouple the component from the dispatcher. You could replace the dispatcher and related pieces with something else and the components would not need to change. 来源: https://stackoverflow.com/questions/29677779/react-flux-whats-the-point-of-actions

Communication between Components

自作多情 提交于 2019-12-09 23:20:35
问题 Here's my situation, I'm very new to react/flux, and just started to play around with it. My toy project is a simple library app. My current state is as follows: i have a component called Login. This component is responsible only to store the currently "logged in" user to be able to deal with latter Borrow/Return buttons in the library. So the user inputs it's name which will be saved into session storage at the moment. my another component is called Library which holds the main logic of my

Avoiding event chains with asynchronous data dependencies

一笑奈何 提交于 2019-12-09 05:16:37
问题 The Facebook Flux dispatcher explicitly prohibits ActionCreators from dispatching other ActionCreators. This restriciton is probably a good idea since it prevents your application from creating event chains. This however becomes an issue as soon as you have Stores containing data from asynchronous ActionCreators that depend on each other. If CategoryProductsStore depends on CategoryStore there doesn't seem to be a way to avoid event chains when without resorting to deferring the follow-up

React-router: Passing data through routes

不问归期 提交于 2019-12-08 17:05:42
问题 I'm trying to figure out the best way to pass data through my routes. I know I can use params but there are certain types of data that don't belong in params. For example: I have an index page that displays a list of applications. Each application has a button next to it which will route you to the view for that application. I want to pass the application itself to the Application handler. However, it doesn't make sense to pass the entire application through params. Though it does make sense