Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

[WIP] Feature/rerendering events based on children #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

oyvindhermansen
Copy link
Owner

@oyvindhermansen oyvindhermansen commented Jul 31, 2018

This PR attempts to solving #14 , but it's just a implementation suggestion. Open for feedback on this one.

The solution i came up with is this:

Every time children of <ImagesLoaded /> updates, the imagesLoaded instance re-initializes and fires all events again. This has been solved using componentDidUpdate for props.children-checks.

When componentDidUpdate fires, I've also added an onUpdate-prop that can be implemented like this:

class ImagesLoadedTest extends React.Component {
  render() {
    return (
       <ImagesLoaded 
         onUpdate={() => console.log('children has updated')}
       >
        {/*....*/}
      </ImagesLoaded>
     )
  }
}

…e and comparing children and then cause a rerender of the imagesLoaded instance. It actually works too.
@oyvindhermansen oyvindhermansen changed the title Feature/rerendering events based on children [WIP] Feature/rerendering events based on children Jul 31, 2018
@codecov-io
Copy link

codecov-io commented Jul 31, 2018

Codecov Report

Merging #15 into master will increase coverage by 29.41%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #15       +/-   ##
=========================================
+ Coverage   70.58%   100%   +29.41%     
=========================================
  Files           1      1               
  Lines          17     24        +7     
  Branches        0      1        +1     
=========================================
+ Hits           12     24       +12     
+ Misses          5      0        -5
Impacted Files Coverage Δ
src/index.js 100% <100%> (+29.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f453c33...2a62cd6. Read the comment docs.

@oyvindhermansen oyvindhermansen changed the title [WIP] Feature/rerendering events based on children Feature/rerendering events based on children Jul 31, 2018
@oyvindhermansen oyvindhermansen changed the title Feature/rerendering events based on children [WIP] Feature/rerendering events based on children Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants