-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
notify about a re-rendered element in props and ignore if it's props are different, improve memoized tracking performance, fix hooks notifications of memoized components were tracked as of inner WDYR component, fix memoized components notifications
- Loading branch information
Showing
11 changed files
with
461 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react' | ||
import ReactDom from 'react-dom' | ||
import {createStore} from 'redux' | ||
import connect from 'react-redux/lib/connect/connect' | ||
import Provider from 'react-redux/lib/components/Provider' | ||
import _ from 'lodash' | ||
|
||
connect = connect.default | ||
Provider = Provider.default | ||
|
||
export default { | ||
description: 'React Redux', | ||
fn({domElement, whyDidYouRender}){ | ||
whyDidYouRender(React) | ||
|
||
const initialState = {a: {b: 'c'}} | ||
|
||
const rootReducer = (state, action) => { | ||
if(action.type === 'randomObj'){ | ||
return {a: {b: `${Math.random()}`}} | ||
} | ||
|
||
if(action.type === 'deepEqlObj'){ | ||
return _.cloneDeep(state) | ||
} | ||
|
||
return state | ||
} | ||
|
||
const store = createStore(rootReducer, initialState) | ||
|
||
const SimpleComponent = ({a, randomObj, deepEqlObj, sameObj}) => { | ||
return ( | ||
<div> | ||
{`{a.b} is: ${a.b}`} | ||
<button onClick={sameObj}>Same State</button> | ||
<button onClick={deepEqlObj}>Deep Equal State</button> | ||
<button onClick={randomObj}>Random Object</button> | ||
</div> | ||
) | ||
} | ||
|
||
const ConnectedSimpleComponent = connect( | ||
state => ({a: state.a}), | ||
({ | ||
randomObj: () => ({type: 'randomObj'}), | ||
deepEqlObj: () => ({type: 'deepEqlObj'}), | ||
sameObj: () => ({type: 'sameObj'}) | ||
}) | ||
)(SimpleComponent) | ||
|
||
ConnectedSimpleComponent.whyDidYouRender = true | ||
|
||
const Main = () => ( | ||
<Provider store={store}> | ||
<ConnectedSimpleComponent/> | ||
</Provider> | ||
) | ||
|
||
ReactDom.render(<Main/>, domElement) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.