jaredLunde / jaredLunde/masonic

Item components seem to be replaced whenever new items are added to array

Open
#119 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.4k
Forks
63
PR merge metrics
No merged PRs in 30d

Description

I'm trying to get an understanding of what the intended behaviour is here.

I was experimenting with adding a fade-in effect to my images when they loaded by storing a boolean `loaded` state in the item which I would flip "onload".

What I found was that all (apart from a seemingly random few that didn't) of my images would fade in every time more data was loaded.

I thought it might be because I wasn't defining an `itemKey` function, but adding one didn't change the behaviour.

Do you have to provide an ItemComponent that is completely pure with no internal state that can be thrown away at any time and re-rendered?

Here's an example https://codesandbox.io/s/masonic-example-forked-ynl73q

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox and inspect how itemKey and ItemComponent behave when new items are appended. Compare the observed remounting and state loss with the intended lifecycle behavior; the issue is done when that behavior is established and a focused fix or test direction is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.