Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Updated: Support React-Hot-Loader compatibility#1168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
markerikson merged 2 commits intomasterfromsupport-react-hot-loader
Jan 20, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@ test/**/lcov.info
test/**/lcov-report
test/react/*/test/**/*.spec.js
test/react/**/src
test/jest-config.json
lcov.info

lib/core/metadata.js
Expand Down
52 changes: 41 additions & 11 deletionssrc/components/connectAdvanced.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -120,7 +120,6 @@ export default function connectAdvanced(
const { pure } = connectOptions

let OuterBaseComponent = Component
let FinalWrappedComponent = WrappedComponent

if (pure) {
OuterBaseComponent = PureComponent
Expand All@@ -131,15 +130,25 @@ export default function connectAdvanced(
let lastState
let lastDerivedProps
let lastStore
let lastSelectorFactoryOptions
let sourceSelector

return function selectDerivedProps(state, props, store) {
return function selectDerivedProps(
state,
props,
store,
selectorFactoryOptions
) {
if (pure && lastProps === props && lastState === state) {
return lastDerivedProps
}

if (store !== lastStore) {
if (
store !== lastStore ||
lastSelectorFactoryOptions !== selectorFactoryOptions
) {
lastStore = store
lastSelectorFactoryOptions = selectorFactoryOptions
sourceSelector = selectorFactory(
store.dispatch,
selectorFactoryOptions
Expand All@@ -157,14 +166,23 @@ export default function connectAdvanced(
}

function makeChildElementSelector() {
let lastChildProps, lastForwardRef, lastChildElement
let lastChildProps, lastForwardRef, lastChildElement, lastComponent

return function selectChildElement(childProps, forwardRef) {
if (childProps !== lastChildProps || forwardRef !== lastForwardRef) {
return function selectChildElement(
WrappedComponent,
childProps,
forwardRef
) {
if (
childProps !== lastChildProps ||
forwardRef !== lastForwardRef ||
lastComponent !== WrappedComponent
) {
lastChildProps = childProps
lastForwardRef = forwardRef
lastComponent = WrappedComponent
lastChildElement = (
<FinalWrappedComponent {...childProps} ref={forwardRef} />
<WrappedComponent {...childProps} ref={forwardRef} />
)
}

Expand All@@ -182,7 +200,14 @@ export default function connectAdvanced(
)
this.selectDerivedProps = makeDerivedPropsSelector()
this.selectChildElement = makeChildElementSelector()
this.renderWrappedComponent = this.renderWrappedComponent.bind(this)
this.indirectRenderWrappedComponent = this.indirectRenderWrappedComponent.bind(
this
)
}

indirectRenderWrappedComponent(value) {
// calling renderWrappedComponent on prototype from indirectRenderWrappedComponent bound to `this`
return this.renderWrappedComponent(value)
}

renderWrappedComponent(value) {
Expand All@@ -206,10 +231,15 @@ export default function connectAdvanced(
let derivedProps = this.selectDerivedProps(
storeState,
wrapperProps,
store
store,
selectorFactoryOptions
)

return this.selectChildElement(derivedProps, forwardedRef)
return this.selectChildElement(
WrappedComponent,
derivedProps,
forwardedRef
)
}

render() {
Expand All@@ -222,7 +252,7 @@ export default function connectAdvanced(

return (
<ContextToUse.Consumer>
{this.renderWrappedComponent}
{this.indirectRenderWrappedComponent}
</ContextToUse.Consumer>
)
}
Expand Down
10 changes: 9 additions & 1 deletiontest/run-tests.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
const npmRun = require('npm-run')
const fs = require('fs')
const path = require('path')
const LATEST_VERSION = '16.6'
const version = process.env.REACT || LATEST_VERSION

Expand DownExpand Up@@ -27,7 +29,13 @@ if (version.toLowerCase() === 'all') {
}
}

const configFilePath = path.join(__dirname, 'jest-config.json')

fs.writeFileSync(configFilePath, JSON.stringify(jestConfig))

const commandLine = `jest -c "${configFilePath}" ${process.argv.slice(2).join(' ')}`

npmRun.execSync(
`jest -c '${JSON.stringify(jestConfig)}' ${process.argv.slice(2).join(' ')}`,
commandLine,
{ stdio: 'inherit' }
)

[8]ページ先頭

©2009-2025 Movatter.jp