Giter Site home page Giter Site logo

ment's Introduction

Hey! Nice to see you.

Welcome to my page!
I'm Omar, Frontend developer from ๐Ÿ‡ช๐Ÿ‡ฌ Cairo, Egypt, currently living in ๐Ÿ‡ฑ๐Ÿ‡ป Riga, Latvia.

Things I code with

React Webpack github actions Google Cloud Platform TypeScript Insomnia Apollo Heroku redux ReactiveX GraphQL Sass Styled Components git npm html5 Brave browser Rollup d3js Prettier MongoDB Nodejs

Where to find me

Github Twitter LinkedIn Medium

ment's People

Contributors

omarzikry avatar

Stargazers

 avatar

Watchers

 avatar

ment's Issues

Consider having your variables stored at the top of your render method

<div className={[classes.text , this.state.currentIndex === index ? classes.activeText : null ].join(' ')} key={image}>

through out the component you are looking up same variables repeatedly. that is not the best approach from a performance point of view.

one good approach is to de-structure your state at the top of the render and use these variables instead of looking up repeatedly

ex :

const {currentIndex, loading, images} = this.state;

the translateValue method is confusing

translateValue = (currentIndex) => {

the translateValue calculates the translation value and set the state with it. on goToPrevSlide you don't use it to set the translate value and use it on goToNextSlide. so it is not very consistent.

this.translateValue(this.state.currentIndex)

1- i think you should unify the way you update your state to avoid confusion during maintenance.
2- considering the asyn nature of react setState I suggest setting both currentIndex & translateValue in the same setState call to make sure both are updated at the same time. the translateValue should just calculate and return the value.

Missing images

./src/components/UI/Card/Card.js

Module not found: Can't resolve '../../../assets/images/Arrow-Right.png' in 'C:\Projects\ment\src\components\UI\Card'

Module not found: Can't resolve '../../../assets/images/Arrow-UP-Right.png' in 'C:\Projects\ment\src\components\UI\Card'

Avoid binding in render

return <NavsLink id={this.state.categories[key].id} active={this.state.categories[key].id === this.state.selected ? true : null} key={key} click={this.handleClick.bind(this, index , this.state.categories[key])}>{this.state.categories[key].name}</NavsLink>

try to avoid binding inside the render. it is quite expensive when it comes to performance and memory.

an alternative option is to use inline arrow function

instead of

onClick ={this.handleClick.bind(this, arguments)}

you can do

onClick = {()=>{this.handleClick( arguments)}

Refactor the ActiveDots component to functional component

class ActiveDots extends Component {

this component is a bit over complicated for its functionality. it doesn't need to be a class component or have an internal state. i did a quick refactor. let me know what do you think?

import React from "react";
import classes from "./ActiveDots.css";

function ActiveDots(props) {
  let { imagesNumber, currentIndex, callIndex } = props;
  const dots = [];
  for (let i = 0; i < imagesNumber; i++) {
    dots.push(
      <p
        key={`dot-no-${i}`}
        className={currentIndex === i ? classes.active : null}
        onClick={() => {
          callIndex(i);
        }}
      >
        {i < 9 ? 0 : ""}
        {i + 1}
      </p>
    );
  }
  return <div className={classes.dots}>{dots}</div>;
}

export default ActiveDots;

never update state directly

this.state.imageNumbers.push(counter)

never update state directly. you should use setState to update state to make sure react knows about it and appropriate state is formed.

NEVER mutate this.state directly, as calling setState() afterwards may replace the mutation you made. Treat this.state as if it were immutable.

setState() does not immediately mutate this.state but creates a pending state transition. Accessing this.state after calling this method can potentially return the existing value.

There is no guarantee of synchronous operation of calls to setState and calls may be batched for performance gains. setState() will always trigger a re-render unless conditional rendering logic is implemented in shouldComponentUpdate().

If mutable objects are being used and the logic cannot be implemented in shouldComponentUpdate(), calling setState() only when the new state differs from the previous state will avoid unnecessary re-renders.

https://reactjs.org/docs/react-component.html#setstate

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.