Discussion: Many providers in application.
See original GitHub issueHi !! 😃 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:
- Created 4 years ago
- Comments:16 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yes of course. I’ll create a sandbox and sent it to you as soon as it’s ready. Thanks.
No problem! Keep trying and find possible bugs!
Let me close this issue. If anybody finds a similar issue, please open a new issue.