Giter Site home page Giter Site logo

Comments (7)

alaycock avatar alaycock commented on August 25, 2024

@fedulovivan did you end up finding a solution for declarative routing? A fork or another package?

from redux-connect.

fedulovivan avatar fedulovivan commented on August 25, 2024

@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.

alaycock avatar alaycock commented on August 25, 2024

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.

abhagsain avatar abhagsain commented on August 25, 2024

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.

alaycock avatar alaycock commented on August 25, 2024

@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.

abhagsain avatar abhagsain commented on August 25, 2024

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.

alaycock avatar alaycock commented on August 25, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.