4 ms·
Could you explain a bit more about how you run the React DevTools in a headless Chrome? As far as I know, headless Chrome can't run extensions.
by mnmkng 6y ago
Could you explain a bit more about how you run the React DevTools in a headless Chrome? As far as I know, headless Chrome can't run extensions.
- Jarred 6y agoI don't precisely mean React Developer Tools because the UI is unnecessary for this usecase, but it provides similar functionality where you can access the state/props from the component instance. The library is: https://github.com/baruchvlz/resq https://github.com/baruchvlz/resq Example code: // resq is the stringified source of the library // page is a Puppeteer page // this line injects resq into the page await page.evaluate(resq); // This finds a React component with a prop "country" set to "us" const usProps = await page.evaluate( `window["resq"].resq$("*", document.querySelector("#__next")).byProps({country: "us"}).props` ); // This finds a React component with a prop "expandRowByClick" set to true const news = await page.evaluate( `window["resq"].resq$("*", document.querySelector("#__next")).byProps({expandRowByClick: true}).props.dataSource` );
- anon9001 6y agoThanks. I didn't know about resq.