Skip to content

Sample State

JamesKoenig edited this page Feb 9, 2021 · 3 revisions

Top-level state example

{
  entities: {
    posts: {
      1: {
        id: 1,
        body: "hello world, this is a barrel!",
        authorId: 1,
        unixEpoch: 1612832752
      },
      2: {
        id: 2,
        body: "incomprehensible gerbil",
        authorId: 2,
        unixEpoch: 1612832782
      },
    },
    users: {
      1: {
        id: 1,
        username: 'admin',
      },
      2: {
        id 2,
        username: 'johnny_go_lucky'
      }
    },
    follows: {
      1: {
        id: 1,
        followedId: 1,
        followerId: 2
      }
    },
    likes: {
      1: {
        id: 1,
        likerId: 1,
        postId: 1,
        unixEpoch: 1612832792
      },
      2: {
        id: 2,
        likerId: 2,
        postId: 1,
        unixEpoch: 1612832852
      },
      3: {
        id: 3,
        likerId: 1,
        postId:  2,
        unixEpoch: 1612832872
      }
    },
    reblogs: {
      1: {
        id: 1,
        postId: 2,
        rebloggerId: 1,
        unixEpoch: 1612832873
      }
    }
  },
  ui: {
    loading: true,
    modal: false
  },
  errors: {
    login: ["Invalid username or password"],
    postForm: ["Post body cannot be blank"],
  },
  session: {
    currentUserId: 2
  }
}
  • top level state-keys are entities, ui, errors, and session
Clone this wiki locally