MCPcopy Create free account
hub / github.com/ReactTraining/react-media / initialize

Method initialize

modules/Media.js:111–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109 };
110
111 initialize() {
112 const targetWindow = this.props.targetWindow || window;
113
114 invariant(
115 typeof targetWindow.matchMedia === "function",
116 "<Media targetWindow> does not support `matchMedia`."
117 );
118
119 const queries = this.props.queries || wrapInQueryObject(this.props.query);
120
121 this.queries = Object.keys(queries).map(name => {
122 const query = queries[name];
123 const qs = typeof query !== "string" ? json2mq(query) : query;
124 const mqListener = new MediaQueryListener(
125 targetWindow,
126 qs,
127 this.updateMatches
128 );
129
130 return { name, mqListener };
131 });
132 }
133
134 componentDidMount() {
135 this.initialize();

Callers 2

constructorMethod · 0.95
componentDidMountMethod · 0.95

Calls 1

wrapInQueryObjectFunction · 0.85

Tested by

no test coverage detected