3 ms·
I personally have never passed a JSX element through an attribute, and I don't see what the use case would be. It smells like an anti-pattern. Why wouldn't you
by pault 8y ago
I personally have never passed a JSX element through an attribute, and I don't see what the use case would be. It smells like an anti-pattern. Why wouldn't you use a render function that returns an element, or just pass the component and create the element in the child?
- tracker1 8y agoThe 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} />} />