Skip to content

Commit

Permalink
refactor: use Object.is to compare new/old props
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed May 14, 2019
1 parent a0186c6 commit c8f8244
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/nerv/src/create-context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Emiter } from './emiter'
import Component from './component'
import { isUndefined } from 'nerv-utils'
import { isUndefined, objectIs } from 'nerv-utils'

export let uid = 0

Expand Down Expand Up @@ -40,7 +40,7 @@ export function createContext<T> (defaultValue: T): Context<T> {
}

componentWillReceiveProps (nextProps: ProviderProps<T>) {
if (this.props.value !== nextProps.value) {
if (!objectIs(this.props.value, nextProps.value)) {
this.emiter.set(nextProps.value)
}
}
Expand Down Expand Up @@ -75,7 +75,7 @@ export function createContext<T> (defaultValue: T): Context<T> {
}

onUpdate = (value: T) => {
if (value !== this.state.value) {
if (!objectIs(value, this.state.value)) {
this.setState({
value: this.getContextValue()
})
Expand Down

0 comments on commit c8f8244

Please sign in to comment.