InterviewHubPRO
Section Overview
Q133

Question 133 of 445

Part 5: React Redux State Management (101 - 134)

30%
React & Modern Frontend (445 Qs)•Part 5: React Redux State Management (101 - 134)

How Relay is different from Redux?

Relay is similar to Redux in that they both use a single store. The main difference is that relay only manages state originated from the server, and all access to the state is used via GraphQL queries (for reading data) and mutations (for changing data). Relay caches the data for you and optimizes data fetching for you, by fetching only changed data and nothing more.

Practical Code Example

graphql
# Relay uses GraphQL fragments co-located with React components:
fragment UserCard_user on User {
  id
  name
  profilePicture
}
# Redux requires manual REST action types, reducers, and normalization.