How to use reducers - 10 common examples

To help you get started, we’ve selected a few reducers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pubpub / pubpub / src / components / AtomTypes / Document / proseEditor / EmbedEditWrapper.jsx View on Github external
render: function() {
		const data = this.props.data || {};
		// Data is the version object with a populated parent field.
		// The parent field is the atomData field

		const atomData = ensureImmutable({ atomData: data.parent, currentVersionData: data });

		if (this.props.mode === 'cite') {
			const number = this.state.citeCount || this.props.citeCount || '?';

			return (
				<span data-source="{this.props.source}" style="{styles.button}">
					<span style="{styles.number}">
						{number}
					</span>
					<div style="{styles.hover}">
						
					</div>
				</span>
			);
		}
github pubpub / pubpub / src / components / AtomTypes / Document / proseEditor / EmbedWrapper.jsx View on Github external
render: function() {
		const data = this.props.data || {};
		// Data is the version object with a populated parent field.
		// The parent field is the atomData field

		const atomData = ensureImmutable({ atomData: data.parent, currentVersionData: data });

		if (this.props.mode === 'cite') {
			const number = this.state.citeCount || this.props.citeCount || '?';

			return (
				<span data-source="{this.props.source}" style="{styles.button}">
					<span style="{styles.number}">
						{number}
					</span>
					<div style="{styles.hover}">
						
					</div>
				</span>
			);
		}
github pubpub / pubpub / src / containers / App / reducer.js View on Github external
case GET_JOURNAL_LOAD:
		return setLoading(state);
	case GET_USER_SUCCESS:
	case GET_USER_FAIL:
	case GET_ATOM_DATA_SUCCESS:
	case GET_ATOM_DATA_FAIL:
	case GET_JOURNAL_SUCCESS:
	case GET_JOURNAL_FAIL:
		return unsetLoading(state, action);

	// case '@@reduxReactRouter/routerDidChange':
	case UNSET_NOT_FOUND:
		return unsetNotFound(state);

	default:
		return ensureImmutable(state);
	}
}
github pubpub / pubpub / src / containers / JournalProfile / reducer.js View on Github external
function addAdminSuccess(state, result) {
	// Add the admin the the list
	return state.merge({
		adminsData: state.get('adminsData').push(ensureImmutable(result))
	});
}
github pubpub / pubpub / src / containers / JournalProfile / reducer.js View on Github external
function addAdminSuccess(state, result) {
	// Add the admin the the list
	return state.merge({
		adminsData: state.get('adminsData').push(ensureImmutable(result))
	});
}
github pubpub / pubpub / src / containers / EmailVerification / reducer.js View on Github external
export default function reducer(state = defaultState, action) {

	switch (action.type) {
	case EMAIL_VERIFICATION_SUCCESS:
		return verificationSuccess(state);

	default:
		return ensureImmutable(state);
	}
}
github pubpub / pubpub / src / containers / JrnlCreate / reducer.js View on Github external
export default function reducer(state = defaultState, action) {

	switch (action.type) {
	case CREATE_JRNL_LOAD:
		return createJrnlLoading(state);
	case CREATE_JRNL_SUCCESS:
		return createJrnlSuccess(state, action.result);
	case CREATE_JRNL_FAIL:
		return createJrnlFailed(state, action.error);

	default:
		return ensureImmutable(state);
	}
}
github pubpub / pubpub / src / containers / Login / reducer.js View on Github external
return loginSuccess(state, action.result.loginData);
	case LOGIN_FAIL:
		return loginFailed(state, action.error);

	case LOGOUT_SUCCESS:
		return loggedOut(state);

	case SIGNUP_DETAILS_SUCCESS:
	case SAVE_SETTINGS_SUCCESS: 
		return signUpDetailsSuccess(state, action.result);

	case EMAIL_VERIFICATION_SUCCESS:
		return verificationSuccess(state);

	default:
		return ensureImmutable(state);
	}
}
github pubpub / pubpub / src / containers / Manage / reducer.js View on Github external
case DELETE_CONTRIBUTOR_LOAD:
		return state;
	case DELETE_CONTRIBUTOR_SUCCESS:
		return deleteContributorSuccess(state, action.result);
	case DELETE_CONTRIBUTOR_FAIL:
		return state;

	case UPDATE_ATOM_DETAILS_LOAD:
		return updateAtomDetailsLoad(state, action.atomID);
	case UPDATE_ATOM_DETAILS_SUCCESS:
		return updateAtomDetailsSuccess(state, action.result, action.atomID);
	case UPDATE_ATOM_DETAILS_FAIL:
		return updateAtomDetailsFail(state, action.error, action.atomID);

	default:
		return ensureImmutable(state);
	}
}
github pubpub / pubpub / src / containers / Atom / reducer.js View on Github external
function addContributorSuccess(state, result) {
	return state.merge({
		contributorsData: state.get('contributorsData').push(ensureImmutable(result))
	});
}

reducers

Library for higher-order manipulation of collections

MIT
Latest version published 12 years ago

Package Health Score

48 / 100
Full package analysis

Popular reducers functions