Skip to content

Commit

Permalink
fix: hot reload
Browse files Browse the repository at this point in the history
  • Loading branch information
foxhound87 committed Mar 14, 2017
1 parent 2b096d8 commit ba93acd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/MatchMediaProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { Component } from 'react';
import { toJS, extendObservable, action, runInAction } from 'mobx';
import { matchMedia, setMatchMediaConfig } from './matchMedia';

let breakpoints;

export default class MatchMediaProvider extends Component {

static propTypes = {
Expand All @@ -11,8 +13,8 @@ export default class MatchMediaProvider extends Component {

constructor(props) {
super(props);
this.breakpoints = this.props.breakpoints;
this.templates = toJS(this.breakpoints);
if (!breakpoints) breakpoints = Object.assign({}, toJS(this.props.breakpoints));
if (!this.templates) this.templates = Object.assign({}, toJS(breakpoints));
}

componentDidMount() {
Expand All @@ -39,7 +41,7 @@ export default class MatchMediaProvider extends Component {

updateBreakpoints = action('update breakpoints', (key, val) => {
const match = matchMedia(val).matches;
extendObservable(this.breakpoints, { [key]: match });
extendObservable(this.props.breakpoints, { [key]: match });
});

render() {
Expand Down
5 changes: 0 additions & 5 deletions tests/test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import breakpoints from './data/breakpoints';
describe('<MatchMediaProvider />', () => {
// test

it('check if MatchMediaProvider breakpoints is observable', () => {
const component = shallow(<MatchMediaProvider breakpoints={breakpoints} />);
expect(isObservable(component.instance().breakpoints)).to.equal(true);
});

it('check if MatchMediaProvider templates is not observable', () => {
const component = shallow(<MatchMediaProvider breakpoints={breakpoints} />);
expect(isObservable(component.instance().templates)).to.equal(false);
Expand Down

0 comments on commit ba93acd

Please sign in to comment.