ReactTraining / react-media

CSS media queries for React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues `import`ing module

axelav opened this issue · comments

I'm unable to import the module as shown in the docs & am failing to find any default export in the source code. I'm trying to pull this into a pretty straightforward app that began using create-react-app so I don't anticipate any compilation issues - I've been wrong before though :).

import Media from 'react-media' gives me an error: export 'default' (imported as 'Media') was not found in 'react-media'

If I require the module in the node cli, I don't see any default property there either.

> var x = require('react-media')
undefined
> x
{ [Function: Media]
  propTypes:
   { defaultMatches: { [Function: bound checkType] isRequired: [Function: bound checkType] },
     query: [Function: bound checkType],
     render: { [Function: bound checkType] isRequired: [Function: bound checkType] },
     children: { [Function: bound checkType] isRequired: [Function: bound checkType] },
     targetWindow: { [Function: bound checkType] isRequired: [Function: bound checkType] } },
  defaultProps: { defaultMatches: true },
  Media: [Circular] }

any ideas where I'm going wrong here?

This latest version broke our build. When we import react-media, we get

Uncaught TypeError: Cannot assign to read only property 'exports' of object '#'
at Object.<anonymous> (react-media.js:1100)

I'm seeing the same thing as the OP but oddly wasn't seeing this a couple of days ago. I'm using 1.6.1 so will try upgrading to 1.7.0

EDIT: it was 1.7.0 which broke the import. I was using ^1.6.1 and npm installed if I revert to 1.6.1 things work ok

Same for us. 1.7.0 is broken but 1.6.1 works.

Sorry for the inconveniences! 1.7.0 was a bad release. I've unpublished it so you should be alright for now.

thanks for the prompt reply @mjackson. I'll give 1.6.1 a shot.

@axelav I just released 1.8.0-rc.1 which should not have this issue. Please give it a shot and let me know how it goes!

npm install react-media@next

@mjackson seems to have done the trick - thanks for the heads up!

Thanks for the feedback, @axelav. Just released in 1.8.0.