redux

Why is my create-react-app showing README.md, not index.html?

混江龙づ霸主 提交于 2019-12-22 08:00:11
问题 Why is my create-react-app showing README.md, not index.html? I've run npm run build -> yarn run deploy, checked the file structure multiple times and read the gh-pages docs. Can't find any other thread with the same issue out there. Thanks. 回答1: You can checkout the documentation from create-react-app regarding this. Add homepage to package.json . Open your package.json and add a homepage field for your project: "homepage": "https://myusername.github.io/my-app", or for a GitHub user page:

Redirect after submit success redux-form

混江龙づ霸主 提交于 2019-12-22 08:00:03
问题 I would like to ask if this is the proper way to redirect to another page after redux-form submit success: const form = reduxForm({ form: 'HeroesCreateComponentForm', validate, onSubmitSuccess: () => { console.log('onSubmitSuccess called (yes, yes I do get called'); browserHistory.push('/') }, }); 回答1: Did you try using next approach? react-router-redux import {push} from 'react-router-redux'; onSubmitSuccess has dispatch function as second parameter. See Redux form. onSubmitSuccess

mapStateToProps for functional component

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 07:04:29
问题 Is there any function similar to mapStateToProps so that we can connect Redux state to the functional component in React? Is passing the state as props from parent component the only solution? 回答1: You can definitely use mapStateToProps with a functional component, the same way you would with a class component. function MyComponent({ propOne }) { return <p>{propOne}</p> } function mapStateToProps(state) { return { propOne: state.propOne }; } export default connect(mapStateToProps)(MyComponent

Component's children should not be mutated

风流意气都作罢 提交于 2019-12-22 06:52:56
问题 I have a react-redux app. I get data via AJAX part of Redux store. This part looks like this: counts: { warning: 0, new: 0, in_hands: 0, completed: 0, rejected: 0 } After changing this values React renders the component render() { var counts = [ { id: 'warning', count: parseInt(this.props.counts.warning), name: 'Внимение' }, { id: 'new', count: parseInt(this.props.counts.new), name: 'Новые' }, { id: 'in_hands', count: parseInt(this.props.counts.in_hands), name: 'В работе' }, { id: 'completed'

Reducing an entire subtree with redux combineReducers

橙三吉。 提交于 2019-12-22 06:00:34
问题 I have a reducer tree that looks like this: module.exports = combineReducers({ routing: routeReducer, app: combineReducers({ setup: combineReducers({ sets, boosters }), servers: combineReducers({ servers }) }) }); Now the setup key holds a form that needs to be reset once we've submitted it. However I have no way to access the entire setup tree because using combineReducers means the reducers only manipulate the data at the leaf nodes of the tree ( sets and boosters in this case). My first

Where to put model specific business logic in a Redux app

怎甘沉沦 提交于 2019-12-22 05:32:08
问题 I am struggling to understand where I should put some of the functionality in the Redux/React app I'm building. My scenario is as follows, in my current app I have several JS classes that wrap around specific json objects and provide methods to get various parts of the data transformed based on certain criteria. For instance, they have a getProperty('name') method which looks up the current host environment and returns the correct sub property value for that host. Where would be the correct

Structuring state management store (ngrx/redux). Flat as representative of data, or nested as representative of view?

半城伤御伤魂 提交于 2019-12-22 05:05:19
问题 I'm using ngrx store, to maintain application state, normalizr to flatten my data from API calls and Immutable. So far it's been working really well, but I'm getting to some more complex data relationships and I was wondering how to proceed with structuring the store. To simplify things, I have two sets of objects. Sessions, and Invoices. One user logs on and can view his list of Sessions. The state in the store is held in an object ISessions : export interface ISessions extends Map<String,

withNavigation can only be used on a view hierarchy of a navigator

雨燕双飞 提交于 2019-12-22 04:49:12
问题 I'm getting the error: Invariant Violation: withNavigation can only be used on a view hierarchy of a navigator. The wrapped component is unable to get access to navigation from props or context I don't know why, because I'm using withNavigation in other components in my app and it works. I don't see a difference in the components that it works on to the one that causes the error. Code: the component: const mapStateToProps = (state: State): Object => ({ alertModal: state.formControls

React-Native ListView renderRow issues passing props. The right way or the wrong way

纵饮孤独 提交于 2019-12-22 04:48:22
问题 Working with a ListView in React-Native, I have seen that is not the same, moving props to the list item, Pass functions as props only with the reference, and invoke the parameters in the child component, or Pass functions as props with parameters defined, and invoke the function with no parameters in the child None of the solutions works. The function invoked are Actions creators of Redux, and dispatched. Is this a issue of Redux or React-Native (maybe ReactJS) This is a snippet, market as /

Best practice to handle errors in Redux and React

杀马特。学长 韩版系。学妹 提交于 2019-12-22 04:10:40
问题 I have an asynchronous function in my redux actions and it returns an object like this in my reducer: { user: {}, fetching: false, fetched, false, error: null } So basically when I start calling the asynchronous function I update the redux state to fetching: true and if the result is successfully fulfilled then fetched:true and fetching:false So I map the redux state to props using connect in react-redux and I added this in my component's render function: if(this.props.fetched) { // Go to