3 ms·
The places I see it the most are in routing and access control components. Here's a convoluted example in my router, not common throughout the application.
by tracker1 8y ago
The places I see it the most are in routing and access control components. Here's a convoluted example in my router, not common throughout the application.
<Route
path="/petition/:petitionId/page/next"
render={({ match }) => (
<InRoles
roles={Roles.pageReviewer}
deny={`/`}
allow={PS(match.params.petitionId, SECTION.PAGES, null, ({ petitionId }) => (
<PageReviewNextPage petition={petitionId} page={'-'} direction={1} />
))}
/>
)}
/>
Route comes from react-router. InRoles is internal to the application and accepts a string or function/component... if it's a string it redirects as appropriate, or renders. if null/empty just hides the result. PS is a function that returns a nested/common component structure.
A more simple example would be...
<Fragment>
<Switch>
<Route exact path="/" render={({ location }) => <Home search={location.search} />} />