Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

because the task #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

because the task #1

wants to merge 1 commit into from

Conversation

trypolski
Copy link

it was interesting

it was interesting

export const store = createStore(reducer, middleware)

// Saving the store changing to the Local Storage
store.subscribe(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice solution.

My idea where to hydrate/ryhydrate the store with a solution outthere. But i such a simple usecase its a very nice solution with no overhead.

onChange={onChange}
onKeyPress={onKeyPress} />
<button onClick={onClick}>
<svg viewBox='0 0 35 35' version='1.1' fill=''><g id='' fill=''><path d='M 16 3 C 8.832031 3 3 8.832031 3 16 C 3 23.167969 8.832031 29 16 29 C 23.167969 29 29 23.167969 29 16 C 29 8.832031 23.167969 3 16 3 Z M 16 5 C 22.085938 5 27 9.914063 27 16 C 27 22.085938 22.085938 27 16 27 C 9.914063 27 5 22.085938 5 16 C 5 9.914063 9.914063 5 16 5 Z M 15 10 L 15 15 L 10 15 L 10 17 L 15 17 L 15 22 L 17 22 L 17 17 L 22 17 L 22 15 L 17 15 L 17 10 Z ' fill='' /></g></svg>
Copy link
Member

@christianbirg christianbirg Jun 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you look at the webpack config, you see an entry for loading svg files with raw loader. so you are able to do:

<div dangerouslySetInnerHTML={{ __html: require("../path/to/assets/icon.svg")}} />

Then you have the possibility to reuse your icons without copying the content of every svg

</div>
)

export default styled(BookmarkAddColumn)`
Copy link
Member

@christianbirg christianbirg Jun 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You misunderstood the concepts of styled components. The right way to use it e.g.

const Input = styled.input`
/* some css */
`

const UsecaseSpecificWrapper = styled.div`
/* some css */
  ${Input} {
    /* manipulate the css for specific usecase
  }
`

const Usecase => () => {
  return (
    <UsecaseSpecificWrapper>
      <Input type="text" />
    </UsecaseSpecificWrapper>
  )
}

)

export default styled(BookmarkCard)`
display: ${props => props.dragging ? '0.5' : '1'};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

display has no numeric values 💃


export default styled(BookmarkCard)`
display: ${props => props.dragging ? '0.5' : '1'};
opacity: ${props => props.dragging ? '0' : '1'};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its hard too read. Instead you could write:

export default styled(BookmarkCard)`
  display: block;
  opacity: 1;
  ${props => props.dragging && `
    display: none;
    opacity: 0.5;
  `}
   /* ....*/
`

}

@connect(mapStateToProps)
export default class DndBookmarkColumnCover extends Component {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 90% of the cases when you dont implement an shouldComponentUpdate, please use the React.PureComponent, this checks the quality of the props and the new props in the render lifecycle to check if he should render itself or not.

@@ -9,7 +9,7 @@ import { routes } from './routes'

import './global'

class Application extends React.PureComponent<{||}> {
class Application extends Component {
Copy link
Member

@christianbirg christianbirg Jun 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, a PureComponent on a first component make no sense 👌

@@ -0,0 +1,19 @@
import React, { Component } from 'react'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats not wrong, but i dont like the style to import the default and a named export

more beautiful is

import React from 'react'

export class Component extends React.Component

or

import { default as React, Component } from 'react'

funny fact: no one knows, that default as is possible 🤓

import DndBookmarkColumnCover from '../../containers/Columns/DndBookmarkColumnCover'

// Visualisation of the column for bookmark cards
const BookmarkColumn = ({ className, id, name, cards }) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional components doesnt give you the opportunity to implement a shouldComponentUpdate. So everytime the parent is updating, this bookmark component is updating too.

As long React doesnt consider shouldComponentUpdate for functional components, you should use functional components only for displaying ui-data. But its more usecase specific

Copy link
Member

@christianbirg christianbirg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the first review it is only a code review (without checking performance etc)

import ShowBookmarkContainer from '../containers/Columns/ShowBookmarkContainer'

const BookmarkApp = () => (
<div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<React.Fragment />?

updatedAt={wasUpdated(itemList[card].updated_at)}
stars={showStars(itemList[card].stargazers_count)}
issues={showIssues(itemList[card].open_issues)}
onClick={(e) => this.handleDeleteBookmark(e)}
Copy link
Member

@christianbirg christianbirg Jun 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the constructor you binded the function. Why are you creating a new anonymous function?

render () {
return (
<BookmarkColumnHead name={this.props.name}
onClick={(e) => this.handleDeleteColumn(e)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, anonymous function is unessary


render () {
return (
<DropDownButton onClick={(e) => this.handleClickButton(e)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -0,0 +1,81 @@
// Creating update info
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the naming is a lil bit awkward

good conventionell namings are src/app/utils.js or src/app/utils/helpers.js

import { injectGlobal } from 'styled-components'

injectGlobal`
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400');

* {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you remove this? box-sizing: border-box; is everytime a good thing 🤓

// Handling changing of search input value
handleOnChange (e) {
const { dispatch } = this.props
// if the value has more than 2 symbols
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { value } = e.target

return (
<div>
<SearchInput
value={this.props.searchtext}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchText ;-)

const itemList = this.props.list
const card = this.props.card
const { connectDragSource, connectDropTarget, isDragging } = this.props

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const updatedAt = wasUpdated(itemList[card].updated_at)

Everything is correct. We prefer executing functions not by passing it in a prop of a component

columns: state.bookmarks.columns }
}

@connect(mapStateToProps)
Copy link
Member

@christianbirg christianbirg Jun 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the second paramater of connect you can pass an object of actions called mapDispatchToProps

// ...
const mapDispatchToProps = {
  addColumn
}

@connect(mapStateToProps, mapDispatchToProps)
class Component from React.Component { /* ... */ } 

/* somewhere in the component */
this.props.addColumn()

so you call the function as a property of a component, but he will execute the function over store.dispatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants