Answer the question
In order to leave comments, you need to log in
Assessment of your level. How to improve the code?
Hello, in recent months I have been actively studying JS and React, I try to write code as much as possible and work on practical tasks, I mainly take information from open sources, but there are no experienced comrades who could evaluate how correctly I use it. Now I plan to start interviewing and I want to at least roughly understand my level and the amount of shit code in my projects.
The last thing I wrote - https://pink-react-app.firebaseapp.com/ - Git - https://github.com/waytolax/pink-react-app
I would appreciate any comments, ratings and advice, what else is worth work to pay attention to.
Answer the question
In order to leave comments, you need to log in
1. Use const
instead let
to define variables that are not redefined in the code. This helps reduce the cognitive load on the person reading the code and is an unspoken standard in React development.
2. Things like globalStyles and store configuration should be placed in separate files. They can grow well over time.
Regarding globalStyles, you can generally put them in a separate css file.
3. Instead of:
{
isModal
? <Route path="/auth" component={AuthPopup} />
: null
}
function mapDispatchToProps(dispatch) {
return {
autoLogin: () => dispatch(autoLogin()),
getBrowser: () => dispatch(getBrowser()),
getMedia: () => dispatch(getMedia())
}
}
const mapDispatchToProps = {
autoLogin,
getBrowser,
getMedia,
};
& label {}
& input {}
& span {}
import {combineReducers} from 'redux';
import photoReducer from './photoReducer';
import authReducer from './authReducer';
import globalReducer from './globalReducer';
export default combineReducers({
photoReducer, authReducer, globalReducer
})
import {combineReducers} from 'redux';
import photo from './photoReducer';
import auth from './authReducer';
import global from './globalReducer';
export default combineReducers({
photo,
auth,
global,
});
return e === 'invalid-email' ? 'Неверно указан e-mail'
: e === 'user-not-found' ? 'Указанный e-mail на найден'
: e === 'wrong-password' ? 'Неверный пароль'
: e === 'email-already-in-use' ? 'Указанный e-mail уже используется'
: e === 'network-request-failed' ? 'Нет подключения к интернету'
: e === 'operation-not-allowed' ? 'Произошла ошибка, попробуйте снова'
: e === 'popup-closed-by-user' ? 'Окно авторизации закрыто пользователем'
: e === 'account-exists-with-different-credential' ? 'Аккаунт уже существует с другими данными, используйте другой способ авторизации'
: e
switch case
import {
SET_ACTIVE,
CHANGE_VALUE,
SET_DEFAULT, UPLOAD,
UPDATE_IMAGE,
SET_IMAGE_ERROR,
SET_LIKE,
SET_COMMENT,
ADD_ARTICLE_SUCCESS,
FETCH_ARTICLES_START,
FETCH_ARTICLES_SUCCESS,
FETCH_ARTICLES_ERROR,
} from '../actions/actionTypes';
function mapStateToProps(state) {
return {
browser: state.globalReducer.browser
}
}
const mapStateToProps = state => ({
browser: browserSelector(state),
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question