Skip to content

Instantly share code, notes, and snippets.

@guillaumewuip
Last active November 12, 2020 06:58
Show Gist options
  • Save guillaumewuip/a06ae49f2b37ee1ba26caac01b761234 to your computer and use it in GitHub Desktop.
Save guillaumewuip/a06ae49f2b37ee1ba26caac01b761234 to your computer and use it in GitHub Desktop.
State and Store in frontend codebases - Redux example - actionCreators
export const fetchUsers = () => ({
type: "FETCH_USERS"
});
export const fetchUsersFailed = () => ({
type: "FETCH_USERS_FAILED"
});
export const fetchUsersSucceeded = (users) => ({
type: "FETCH_USERS_SUCCEEDED",
payload: {
users
}
});
export const createUser = (firstName, lastName, picture) => ({
type: "CREATE_USER",
payload: {
id: Math.round(Math.random() * 1000000),
firstName,
lastName,
picture
}
});
export const createUserFailed = () => ({ type: "CREATE_USER_FAILED" });
export const createUserSucceeded = (payload) => ({
type: "CREATE_USER_SUCCEEDED",
payload: { user: payload }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment