Micro-Frontends-practice icon indicating copy to clipboard operation
Micro-Frontends-practice copied to clipboard

跳转creatreactapp下,报如下错误

Open fancyluo88 opened this issue 4 years ago • 2 comments

index.js:184 Uncaught creatreactapp: Application 'creatreactapp' died in status LOADING_SOURCE_CODE: You need to export the functional lifecycles in creatreactapp entry at http://localhost:3000/static/js/0.chunk.js:5714:25 at step (http://localhost:3000/static/js/0.chunk.js:46961:17) at Object.next (http://localhost:3000/static/js/0.chunk.js:46892:14) at fulfilled (http://localhost:3000/static/js/0.chunk.js:46845:24)

fancyluo88 avatar Apr 22 '20 13:04 fancyluo88

感觉这个项目根本就没用啊,根本就跑步起来。

HuanxinHu avatar Aug 03 '20 07:08 HuanxinHu

index.js:184 Uncaught creatreactapp: Application 'creatreactapp' died in status LOADING_SOURCE_CODE: You need to export the functional lifecycles in creatreactapp entry at http://localhost:3000/static/js/0.chunk.js:5714:25 at step (http://localhost:3000/static/js/0.chunk.js:46961:17) at Object.next (http://localhost:3000/static/js/0.chunk.js:46892:14) at fulfilled (http://localhost:3000/static/js/0.chunk.js:46845:24)

这个问题官方已经解决了,需要在子应用加入主应用的entry相关生命周期


/**
 * The bootstrap will only be called once when the child application is initialized.
 * The next time the child application re-enters, the mount hook will be called directly, and bootstrap will not be triggered repeatedly.
 * Usually we can do some initialization of global variables here,
 * such as application-level caches that will not be destroyed during the unmount phase.
 */
export async function bootstrap() {
  console.log('react app bootstraped');
}
/**
 * The mount method is called every time the application enters,
 * usually we trigger the application's rendering method here.
 */
export async function mount(props) {
  ReactDOM.render(<React.StrictMode><App /></React.StrictMode>, props.container ? props.container.querySelector('#root') : document.getElementById('root'));
}
/**
 * Methods that are called each time the application is switched/unloaded,
 * usually in this case we uninstall the application instance of the subapplication.
 */
export async function unmount(props) {
  ReactDOM.unmountComponentAtNode(props.container ? props.container.querySelector('#root') : document.getElementById('root'));
}
/**
 * Optional lifecycle,just available with loadMicroApp way
 */
export async function update(props) {
  console.log('update props', props);
}

Yvette2333 avatar Dec 13 '20 14:12 Yvette2333