question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion: Many providers in application.

See original GitHub issue

Hi !! 😃 Rafael here again. lol

I have a provider as below:

import React, { useReducer } from "react";
import { createContainer } from "react-tracked";

const reducer = (state, newObject) => { return { ...state, ...newObject } };

export const { Provider, useTracked: useContainerState } = createContainer(
    () => useReducer(reducer, {})
);

export const ContainerProvider = ({ children }) => <Provider> {children} </Provider> ;

And I’m using that provider wrapping any route of my application. To create a context to any component route.

const PrivateRoute = ({ component: Component, ...rest }) => {
    return (
        <Route
            {...rest}
            render={props => validLogin()
                ? <ContainerProvider> <Component {...props} {...rest} /> </ContainerProvider>
                : <Redirect to="/login"/>
            }
        />
    );
};

const WorkflowRoutes = () => (
    <Switch>
        <PrivateRoute exact path="/dashboard" component={Dashboard} />
        <PrivateRoute exact path="/audit" component={Audit} />
    ....

The problem is…
If I access the dashboard module and then access the audit module, the object contained in the state (useTracked) in audit module will have all the objects that were in the dashboard. It is sharing the data instead of having one provider for each module.

Is there any way to create a unique provider for each module? I imagine this is happening because the reducer is not being created in ContainerProvider. Is there any way around this?

Thanks a lot again !

Rafael.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rbgfloripacommented, Sep 17, 2019

yes of course. I’ll create a sandbox and sent it to you as soon as it’s ready. Thanks.

0reactions
dai-shicommented, Aug 13, 2020

No problem! Keep trying and find possible bugs!

Let me close this issue. If anybody finds a similar issue, please open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is application service provider (ASP)? - TechTarget
SaaS vendors manage software they have developed on their own or, in many cases, offer both their own applications and those developed by...
Read more >
Application Service Providers (ASPs) Are Quickly | Geek Culture
Application Service Providers and Hosting​​ These companies provide businesses with access to enterprise software like payroll processing, human ...
Read more >
Mobile Devices and Apps for Health Care Professionals - NCBI
The many uses for mobile devices and types of medical apps that fall under these categories are discussed in the following section, and...
Read more >
What is Application Service Provider (ASP) ? - GeeksforGeeks
It is a third-party unit which provides access to software applications and other services to individuals, multiple customers or organizations ...
Read more >
Providers: Forms - Indiana Medicaid - IN.gov
Note: Many of these forms have been integrated into the IHCP Provider Healthcare Portal (Portal) and, therefore, are not required for transactions conducted ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found