Giter VIP home page Giter VIP logo

react-performance's People

Contributors

0xnoob avatar ahmedaymanm avatar allcontributors[bot] avatar andrewmcodes avatar aprillion avatar arjenbloemsma avatar bobbywarner avatar cjthornburg avatar d4vsanchez avatar emzoumpo avatar esplito avatar fensterbank avatar foxandxss avatar gwanduke avatar jacobparis avatar jdorfman avatar jmagrippis avatar jstheoriginal avatar kentcdodds avatar lochmess avatar lucianoayres avatar marcosnasa avatar marcosvega91 avatar marioleed avatar matchai avatar milamer avatar mstosio avatar reignable avatar snaptags avatar xhocopuff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-performance's Issues

Can't access examples/code-splitting/main.js

Hi,

at the end of the first exercise, it says:

Notes

Another thing which we won’t cover in this workshop, but you should look into later, is using the webpackChunkName magic comment which will allow webpack to place common modules in the same chunk. This is good for components which you want loaded together in the same chunk (to reduce multiple requests for multiple modules which will likely be needed together).
You can play around with this in the src/examples/code-splitting directory.

the files contains a link:

// http://localhost:3000/isolated/examples/code-splitting/main.js

but visiting this link doesn't work, neither in development nor production build:

Sorry... nothing here. To open one of the exercises, go to /exerciseNumber, for example: /1

I played around a little bit: I can only visit sites that are directly under examples, that's why the other example unnecessary-rerenders.js are accessible.
My solution was to simply move the main.js one folder up and update the module imports, because importing from deeper directories still works.
I didn't create a pull request because I assume there is a problem somewhere else, which prevents accessing the deeper directory directly?

Exercise 3 - example unnecessary-rerenders.js - memoizing CountButton doesn't stop it from unnecessary re-renders.

Hello,
using React.memo on CountButton doesn't stop it from rerendering, because it will always receive a new instance of the increment function.

There are a couple of ways to fix this:

  • simply don't memoize CountButton, as the focus of the example is on NameInput anyway.
  • use React.useCallback on increment before passing it as a property (don't think that's a good solution, though).
  • instead of increment, pass setCount as a property to CountButton and define increment inside that component.
  • at the end of the example, it says "that people can make the mistake of wrapping
    everything in React.memo which can actually slow down your app in some cases
    and in all cases it makes your code more complex."
    maybe point them to look at the memoized CountButton in the React DevTools as an example of this? Because that's what I thought it boiled down to.

I hope this isn't too much nitpicking from me! :3

Uncaught ReferenceError: process is not defined

This error appears in the console when ever i make changes to an exercise file. After the changes, when i go back to the exercise I am not able to scroll. Looks like there's an overlay (iframe) blocking the view. I have to refresh to get everything working

Screenshot 2022-04-22 at 7 23 05 AM

Exercice 1 Final has a huge chunk

Hey 👋

I'm following the first lesson right now about code-splitting and I noticed something odd: one of the initial chunk is huge. It's 867KB gzipped and 3.5MB once decompressed 😱 .

image

I'm using this page: https://react-performance.netlify.app/isolated/final/01.js

As this exercice is about avoiding loading unnecessary JS, this is misleading. In the end, what we save with code-splitting is quite small compared to this chunk.

In the video, I don't see it so it might be a regression.

Issue with Exercise 2 Extra Credit 2, Exercise 3 in regards to web workers.

In exercise 2, extra credit 2 when adding the web worker I get this error:
unknown

Which comes up both when I add the web worker myself and also when I check the final solution for the extra credit.

The error is also present in Exercise 3 and it prevents anything from rendering.

When building the workshop I got the following error which may be related:

webpack compiled with 1 error```

May be related to this issue:
https://github.com/kentcdodds/react-performance/issues/112

Exercise 3 extra credit 1, avoid re-renders in selectedItem

In exercise 3 extra credit 1, you mention that you can do the same with selectedItem, I tied that out, and only had problems because I forgot to modify line 68 if (prevProps.selectedItem !== nextProps.selectedItem) return false
We need to change it to:

if (prevProps.selectedItem !== nextProps.selectedItem) {
    const id = prevProps.item.id
    const wasPrevSelected = prevProps.selectedItem?.id === id
    const isNowSelected = nextProps.selectedItem?.id === id
    return wasPrevSelected === isNowSelected
}

You can see it working with the Henderson selected example
image

On a second note, your CONTRIBUTING.md is outdated, the egghead link is now https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github

Should Tracing API exercise be removed? API removed in React 17

Hello!

I had a question in the Discord channel on whether the experimental trace API exercise should be removed (exercise 7 extra credit 1). Per this link found in the react docs: https://fb.me/react-interaction-tracing, the tracing API was removed in React 17.

Interestingly though, I see "react": "^17.0.2", in the dependencies and can still see interactions in the exercise:

image

Maybe it was just removed from the dev tools? Not sure.
Let me know if you need anything else.

Thanks!

Uncaught TypeError: (0 , _workerized_filter_cities__WEBPACK_IMPORTED_MODULE_2__.getItems) is not a function

This is part of what shows up in #113 and then probably #112, except I'm not getting the (apparently now fixed) undefined error, just the not a function errors related to the workerization.

I still get the rest of the error from #112, and it happens in my exercises for lessons 3 and 4 as well as the final versions. Here is a screenshot from the final for exercise 3, showing nothing rendering, and the console errors.

image

GraphQL responds with 404

Videos at https://epicreact.dev/modules/react-performance/react-performance-welcome stuck on loading. There is an error message in the console:

POST https://app.egghead.io/graphql 404

GraphQL Error (Code: 404): {"response":{"error":"","status":404},"request":{"query":"\n  query LessonData($slug: String!) {\n    video_resource(slug: $slug) {\n      slug\n      subtitles_url\n      lesson_view_url\n      dash_url\n      hls_url\n    }\n  }\n","variables":{"slug":"egghead-er-05-00-01-react-performance-welcome"}}}

question: Exercise 5, less render than you

Hey @kentcdodds ,

Thanks a lot for this great course.
I have a question about 5th exercise, i have less renders than you without any change :
image

Do you know why ? Maybe a flamegraph bug ? 🤔
Because i have all cells in ranked.

Thanks a lot, have a nice day :)

Only rerender ListItem when isSelected changes

Hey Kent, thanks for the great course over at epic react.

I tried to write a compare function for React.memo's propsAreEqual argument in Exercise 3.1. But I'm not sure if you would like a PR for that.

function listItemPropsAreEqual(
  {
    selectedItem: prevSelectedItem,
    item: prevItem,
    index: prevIndex,
    highlightedIndex: prevHighlightedIndex,
    ...prevProps
  },
  {
    selectedItem: nextSelectedItem,
    item: nextItem,
    index: nextIndex,
    highlightedIndex: nextHighlightedIndex,
    ...nextProps
  },
) {
  const isSelected = nextSelectedItem?.id === nextItem.id
  const wasSelected = prevSelectedItem?.id === prevItem.id

  if (isSelected !== wasSelected) {
    return false
  }

  const isHighlighted = nextHighlightedIndex === nextIndex
  const wasHighlighted = prevHighlightedIndex === prevIndex

  if (isHighlighted !== wasHighlighted) {
    return false
  }

  return shallowEqualProps(prevProps, nextProps)
}

I also had to write a custom shallowEqual function as ListItem passes all extra props to the getItemProps prop getter and therefore would need to update if one of those props changes.

function shallowEqualProps(prevProps, nextProps) {
  if (prevProps === nextProps) {
    return true
  }
  const prevPropsKeys = Object.keys(prevProps)
  const nextPropsKeys = Object.keys(nextProps)

  if (prevPropsKeys.length !== nextPropsKeys.length) {
    return false
  }

  return prevPropsKeys.every(
    propKey =>
      nextProps.hasOwnProperty(propKey) &&
      prevProps[propKey] === nextProps[propKey],
  )
}

Fix 04.js

Hello, I create PR #35 that fixes a bug that caused the items list to scroll to the top when hovering out of it.
on debugging, I found that onHighlightedIndexChange returns highlightedIndex with value of -1 when the mouse moves out of the list, this makes rowVirtualizer.scrollToIndex methof to scroll to the top

scroll bug

have a good day! 😄 🎈

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.