Giter Site home page Giter Site logo

react-media-query-hoc's Issues

State being updated on window resize, context isn't.

Hello,

I have a Component that is wrapped by the withMedia HOC.

When I resize the window, I can see that the MediaQueryProvider's state is currently updating to the correct media device, but the context of the withMedia HOC is not.

In order for the wrapped components and withMediaHOC to reflect the right device in context/props, I have to refresh the page.

I'm currently using React 16.

Here is how I'm using the MediaQueryProvider

screen shot 2018-05-25 at 9 50 32 am

Context is not updated when state changes

I'm using React 16 with a component wrapped inside the withMedia HOC. Media queries works fine, refreshing the whole page at different resolutions I see that the state/context of the MediaQueryProvider component is correctly updated. However, resizing the window updates the state but not the context, so any child component won't see the new media queries values and won't trigger any layout change.

Fix Travis badge

The travis CI badge links to a build which says
"No builds for this repository" but there was builds at some point?

I think the config has gone haywire - requires some small investigation to resolve

withMedia hoc can cause jumpy behaviour

Should withMedia render the component before context.media is defined?
We've seen cases where we can see a jump where it renders the default view, and then when the media prop is defined it jumps to say the mobile view.
I believe react-responsive won't render its children before media is defined.

Allow passing of values to matchmedia for Server Side Rendering

Server rendering can be done if there is way to pass static values such as deviceWidth, deviceHeight etc so that on client mount there is no client / server mismatch issues (matchmedia lib can handle this)

Interface could be:

const App = (props) => {
  const customQueries = {
    verySmall: 'screen and (max-width: 300px)',
    someOtherMediaQuery: 'screen and (min-width: 301px)',
  }; 

  const values = {
    deviceWidth: 500,
    orientation: 'portrait',
  };

  return (
    <MediaQueryProvider queries={customQueries} values={values}>
      <TheRestOfMyApp />
    </MediaQueryProvider>
  );
};

Prevent MediaQueryProvider from printing any additional div

As the MediaQueryProvider component should be used at the root-level of the application as stated in the docs, it makes no sense that it adds an additional element to the HTML structure. In my case, using a layout based on flexboxes that div that gets printed is a problem. Maybe you could use Children.only like Apollo Client does to make this component "transparent"?

Changelog for v1.0 ?

Hello,

Is it possible to have a changelog or at least the breaking changes from v0.5 to v1.0 ?

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.