Conversation
| BrowserRouter, | ||
| Route, | ||
| Switch, | ||
| withRouter, |
There was a problem hiding this comment.
it seems like you don't use it, so we make remove it
| return ( | ||
| <div> | ||
|
|
||
| <Route path = "/home" component={In}/> |
There was a problem hiding this comment.
add , and exact prop to each Route could be more safer decision
| @@ -0,0 +1,6 @@ | |||
| export const incrementCounter = (payload) => { | |||
There was a problem hiding this comment.
why do you need an increment counter?
| padding: 0; | ||
| font-family: sans-serif; | ||
| } | ||
| #first { |
There was a problem hiding this comment.
it's always better to use classNames over id. Using ids is a pitfall for bugs
| import {incrementCounter} from '../../actions'; | ||
|
|
||
|
|
||
| let url3 = 'https://flatearth-api.herokuapp.com/api/v1/auth/login' |
There was a problem hiding this comment.
url3 is bad name, it could be something like
const authURL = ...but from architecture point of view it's still no good to give component knowledge about URL, fetching resources, headers, etc. It should be another file, store in folder service with file auth-api
and auth-api should have something like this
// auth-api.js
const URLprefix = 'https://flatearth-api.herokuapp.com/api/v1/auth/'
const authAPI = {
login(user) {
const {
user,
password
} = user;
const loginURL = `${urlPrefix}/login`;
return fetch(loginURL, {}).then(data => data.json()) // with required headers, meta information, etc
}
}So you just importing such file and you component working with single method.
That knowledge about splitting application for different layers makes huge different from "common" developer and good developer
|
|
||
|
|
||
| let mapStateToProps = (state) => { | ||
| console.log(`stateghjkgkkg`, state.counter.counter) |
| token1: state.counter.counter | ||
| } | ||
| } | ||
| export default connect(mapStateToProps)(User); No newline at end of file |
There was a problem hiding this comment.
it's bad practice to export components in such manner without naming
| withRouter, | ||
| } from "react-router-dom"; | ||
|
|
||
| //const store = createStore(allReducers); |
There was a problem hiding this comment.
the same about commented code, we don't need it in production
| @@ -0,0 +1,7 @@ | |||
| import {createStore, applyMiddleware} from 'redux'; | |||
|
|
|||
|
|
||
|
|
||
| import {reducer} from './reducers/reducer'; | ||
|
|
No description provided.