Comments (7)
@fedulovivan did you end up finding a solution for declarative routing? A fork or another package?
from redux-connect.
@alaycock Yes, finally I have managed to launch our legacy code with latest version of redux-connect, but this approach required to use some monkey-patching and final solution appeared to be not that elegant (I even cannot remember what particulary was changed).
Being honest, now we are trying to eliminate usage of async connect in our code and switch to following architecture for the root component for the page:
const PageComponent: React.FC<PageComponentProps> = (): JSX.Element => {
// state
const [startInitialLoadTriggered, setStartInitialLoadTriggered] = useState(false);
// selectors
const isPendingInitialLoad = useSelector(selectors.isPendingInitialLoad);
// actions
const startInitialLoad = useAction(actions.startInitialLoad);
// effects
// trigger initial load
useEffect(() => {
setStartInitialLoadTriggered(true);
startInitialLoad();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
// minor imperfection after elimination of redux-connect:
// we need to skip first render
// since effect with startInitialLoad is not yet executed
if (!startInitialLoadTriggered) return null;
return (
<Page title={PAGE_TITLE} bodyClassName={style.root}>
</Page>
);
}
action startInitialLoad is handled by folowing epic which triggers fetching of required data
// fetch initial data on page load
(action$, state$) => action$.pipe(
ofType(actions.startInitialLoad.TYPE),
mergeMap(() => {
return of(
actions.fetchEtities(),
actions.fetchEtitityAttributes(),
);
})
),
isPendingInitialLoad selector returns true if any of async operations (fetch requests) are still in progress.
from redux-connect.
Thanks, @fedulovivan for the response and the example! I was exploring something similar, but removing redux-connect also seems like a potential solution.
from redux-connect.
Thanks, @fedulovivan for the response and the example! I was exploring something similar, but removing redux-connect also seems like a potential solution.
@alaycock Were you able to remove redux-connect
? If so what else did you choose?
from redux-connect.
@abhagsain we're still running it. There's some pretty tight coupling between redux-connect
and some of the other packages we depend upon which can make it hard to remove. We just found a proprietary solution for code splitting and are running that instead.
from redux-connect.
Got it. @alaycock could you please tell me which version of react
, react-router/react-router-dom
are you using with redux-connect
? I'm trying to upgrade from [email protected]
to [email protected]
and react-router@v3
to react-router-dom@v4
but having a hard time.
from redux-connect.
@abhagsain your best bet is to look at the package.json for the peer dependencies if you haven't already.
You should be able to upgrade to a more recent version of React without any issues while continuing to use react-router 3. That is a small step forward.
As for our versions, we're pretty far behind. We're on [email protected]
which requires react-router 3, so we're in a similar boat as you. Upgrading to a more recent version of react-router can be a pretty significant undertaking, which is why I'd aim to remove redux-connect before trying to do that upgrade. Trying to do both at the same time would make the project more complex than it needs to be, in my view.
I haven't actually looked into if that's reasonable or possible, so you'll have to do your own exploration.
from redux-connect.
Related Issues (20)
- Use it with simple async fetch?
- Lazy component load HOT 4
- Suggestion: previous location and params
- asyncConnect does not fire with browser back button
- can't install 7.0.0 HOT 1
- Can't resolve 'react-router-config/renderRoutes' in node_moduels/redux-connect/lib/components HOT 1
- How to use with redux-thunk ? HOT 1
- asyncConnect promises are not called when running jest test
- Wait for Nested Promises to resolve HOT 2
- Wait to render before promise is resolved. HOT 13
- Passing async response data as prop. HOT 1
- Using ownProps inside the preload action HOT 2
- react-redux 6.0.0 support HOT 8
- Router render v3 and ReduxAsyncConnect
- Component attempts to render before asyncConnect promise is fired/resolved
- Cannot read property 'store' of undefined HOT 3
- support for react-router 5 and react-redux 7?
- Use JSX routes insted of static array of routes
- Does it support react router 3?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-connect.