Conditional rendering in React refers to rendering different content based on certain conditions. This can be achieved using JavaScript's conditional statements (if/else) or by using the ternary operator within JSX.
How would you show a loading spinner while data is being fetched and hide it once the data arrives?
If you receive a boolean prop isAdmin, how would you render an admin panel only when it's true?
What happens if a component's render method returns null?
We have a component that sometimes receives an array of items and sometimes null, and it currently crashes. Walk me through how you'd guard the rendering and why the crash occurs.
Explain the trade‑offs between using a ternary operator versus logical && for conditionally rendering a large list.
During a code review you notice a component re‑renders unnecessarily because a conditional block creates a new function each render. How would you fix it?
Our dashboard renders dozens of widgets, each conditionally displayed based on user permissions fetched from an API. How would you design the conditional rendering to minimize performance impact and avoid prop‑drilling?
We need to implement feature flags across many components without littering each component with if (flag). Describe a pattern you’d use and its implications for bundle size and testing.
A component uses many nested ternary expressions, making the JSX hard to read. How would you refactor it while preserving behavior and ensuring type safety?
Our product is migrating from a legacy class‑based codebase to functional components with hooks. The legacy code uses many if statements inside render. What strategy would you propose for systematically replacing those with modern conditional rendering patterns, considering backward compatibility and team adoption?
We plan to introduce a global theming system that conditionally renders different UI trees based on theme and locale. How would you architect this to keep the codebase maintainable across multiple teams and avoid duplication?
Discuss the long‑term maintenance implications of using inline conditional logic versus a dedicated rendering abstraction (e.g., higher‑order component or render prop) in a large‑scale application.