Hav
Hav

Reputation: 938

React, rendering components based on user priviliges/roles

I am wondering what would be the best approach to implement a mechanism of rendering components based on user privileges/roles. My first thought was to implement a higher order component which will be connected to redux store and conditionally render or not wrapped components. It should work just fine but I am worrying about performance of such solution. I will probably end up with dozens of such wrapped components.

Is there a better way to handle this cleanly without too much performance overhead?

Upvotes: 0

Views: 189

Answers (1)

kngroo
kngroo

Reputation: 462

Seems like your described solution is no different than having hundreds/thousands of Redux connected components in general, in which case performance should not be an issue.

see: https://github.com/reactjs/redux/blob/master/docs/faq/Performance.md

Upvotes: 1

Related Questions