react-redux

connect and withRouter issue

≯℡__Kan透↙ 提交于 2020-07-16 20:07:07
问题 I am using Redux and React for my project. I have some Routes in App.js. I also use the connect function in react-redux in my project. To prevent update blocking issue, I usually wrapped my component in this way withRouter(connect(mapStateToProps, mapDispatchToProps)(App)), However, If I changed order of withRouter and connect it doesn't work: connect(mapStateToProps, mapDispatchToProps)(withRouter(App)) I have console.log the props in App.js. It already receives location and history props. I

connect and withRouter issue

孤者浪人 提交于 2020-07-16 20:03:05
问题 I am using Redux and React for my project. I have some Routes in App.js. I also use the connect function in react-redux in my project. To prevent update blocking issue, I usually wrapped my component in this way withRouter(connect(mapStateToProps, mapDispatchToProps)(App)), However, If I changed order of withRouter and connect it doesn't work: connect(mapStateToProps, mapDispatchToProps)(withRouter(App)) I have console.log the props in App.js. It already receives location and history props. I

Implementing check boxes in react

六眼飞鱼酱① 提交于 2020-07-10 10:27:46
问题 I am trying to implement product list table. What i have done is as under, import React, { Component } from 'react'; import { Row, Col, Card, CardBody } from 'reactstrap'; import { withRouter, Link } from 'react-router-dom'; import { activateAuthLayout, onLoad } from '../../../store/actions'; import { connect } from 'react-redux'; import Settingmenu from '../Subpages/Settingmenu'; //images import default_image from '../../../images/users/user-1.jpg'; const ListProducts = props => { if (props

Async function is not working when pass on as props

痞子三分冷 提交于 2020-07-10 08:44:04
问题 I have Listval function in parent component "Navbar", that i like to pass on as props to child component "Menu" as Listvalll. But it does not work. I intend to bring it as props for on click in Modal of the Menu component. The function works ok when it is run within Menu, but is not working when i pasted it in the parent component. Please see the sandbox: https://codesandbox.io/s/relaxed-shape-omjsc 来源: https://stackoverflow.com/questions/62584816/async-function-is-not-working-when-pass-on-as

React Native: when you navigate away from a component, does that component ever get un-mounted?

送分小仙女□ 提交于 2020-07-09 17:10:39
问题 In my React Native app, if I have a stack navigator and I navigate from screenA to screenB with this.props.navigation.navigate('screenB') , is it possible that screenA would ever get un-mounted? The reason I ask is that when screenA mounts, I make an API call that will load a resource that will be available in all screens via Redux. I might navigate to screenB while that API call is still in progress. So I want to know if it's possible that my navigating to screenB too soon could prevent the

redux-thunk and in app architecture - want to render only views in views and dispatch GET actions in separate component

纵然是瞬间 提交于 2020-07-09 12:48:12
问题 I am using react-redux and redux-thunk in my application and there are two things I am trying to do: I want to be able to share the results of a GET request in two components. I know you can do this by connecting the two components to the store, but I want to make it so if the user lands on X page, then Y page cannot make the same GET request again (these two components are Thumbnail and Carousel). In other words, the GET request should be made once (not 100% sure what best practice is here

React: URL Profile ID doesn't match (match.params.id)

左心房为你撑大大i 提交于 2020-07-09 05:09:01
问题 So whenever I clicked the View Profile Link <Link to={`/profile/${_id}`} className="btn btn-primary"> View Profile </Link> It shows in the URL the User ID of the Profile which is Good. But whenever I Clicked it to Match it with this Button I get an error. const Profile = ({ getProfileById, match }) => { useEffect(() => { getProfileById(match.params.id); }, [getProfileById]); return <div>test</div>; }; I get on my console React Hook useEffect has a missing dependency: 'match.params.id'. Either

How to maintain Scroll Position When Adding Content to the Top of a Container in React

一世执手 提交于 2020-07-07 08:35:54
问题 I am trying to create messaging app in react. When ever the scroll is at the top, it dispatch an action to fetch older messages but the scroll still stays at top even after the messages are fetched so it keeps on firing the dispatch action to get more messages. Does any one know how to main the scroll position when adding content to the top of parent containers's children so that scroll position doesn't stay at top and stops firing request. <Fragment> {messagesLoading && messages.length > 0 &

How to maintain Scroll Position When Adding Content to the Top of a Container in React

北城余情 提交于 2020-07-07 08:31:56
问题 I am trying to create messaging app in react. When ever the scroll is at the top, it dispatch an action to fetch older messages but the scroll still stays at top even after the messages are fetched so it keeps on firing the dispatch action to get more messages. Does any one know how to main the scroll position when adding content to the top of parent containers's children so that scroll position doesn't stay at top and stops firing request. <Fragment> {messagesLoading && messages.length > 0 &

Why is dispatch() causing redirect to initialRouteName in react-navigation?

倾然丶 夕夏残阳落幕 提交于 2020-06-29 04:30:32
问题 I'm having a problem where every dispatch causes the navigator to redirect to my initialRouteName . Because of my componentDidUpdate methods, I eventually land on the correct screen, but only in some cases. I have used ReactNavigation several times before without any problems. The only thing that stands out is that <NavigationContainer onStateChange is getting called once for all dispatch'd action, not just those under the navigator reducer. Is that normal? root.js import 'react-native