MCPcopy Index your code
hub / github.com/react/react / componentDidMount

Function componentDidMount

fixtures/attribute-behavior/src/App.js:801–862  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

799 };
800
801 async componentDidMount() {
802 const sources = {
803 ReactStable: 'https://unpkg.com/react@latest/umd/react.development.js',
804 ReactDOMStable:
805 'https://unpkg.com/react-dom@latest/umd/react-dom.development.js',
806 ReactDOMServerStable:
807 'https://unpkg.com/react-dom@latest/umd/react-dom-server.browser.development.js',
808 ReactNext: '/react.development.js',
809 ReactDOMNext: '/react-dom.development.js',
810 ReactDOMServerNext: '/react-dom-server.browser.development.js',
811 };
812 const codePromises = Object.values(sources).map(src =>
813 fetch(src).then(res => res.text())
814 );
815 const codesByIndex = await Promise.all(codePromises);
816
817 const pool = [];
818 function initGlobals(attribute, type) {
819 if (useFastMode) {
820 // Note: this is not giving correct results for warnings.
821 // But it's much faster.
822 if (pool[0]) {
823 return pool[0].globals;
824 }
825 } else {
826 document.title = `${attribute.name} (${type.name})`;
827 }
828
829 // Creating globals for every single test is too slow.
830 // However caching them between runs won't work for the same attribute names
831 // because warnings will be deduplicated. As a result, we only share globals
832 // between different attribute names.
833 for (let i = 0; i < pool.length; i++) {
834 if (!pool[i].testedAttributes.has(attribute.name)) {
835 pool[i].testedAttributes.add(attribute.name);
836 return pool[i].globals;
837 }
838 }
839
840 let globals = {};
841 Object.keys(sources).forEach((name, i) => {
842 eval.call(window, codesByIndex[i]); // eslint-disable-line
843 globals[name] = window[name.replace(/Stable|Next/g, '')];
844 });
845
846 // Cache for future use (for different attributes).
847 pool.push({
848 globals,
849 testedAttributes: new Set([attribute.name]),
850 });
851
852 return globals;
853 }
854
855 const {table, rowPatternHashes} = await prepareState(initGlobals);
856 document.title = 'Ready';
857
858 this.setState({

Callers

nothing calls this directly

Calls 5

fetchFunction · 0.85
prepareStateFunction · 0.85
mapMethod · 0.65
valuesMethod · 0.65
thenMethod · 0.65

Tested by

no test coverage detected