Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持 [email protected] #8

Closed
CJY0208 opened this issue Jun 10, 2020 · 0 comments · Fixed by #9
Closed

支持 [email protected] #8

CJY0208 opened this issue Jun 10, 2020 · 0 comments · Fixed by #9

Comments

@CJY0208
Copy link
Member

CJY0208 commented Jun 10, 2020

之前对 [email protected] 的配置不太了解,一直没能支持 3.x

感谢 @AlanSean 同学在 CJY0208/react-activation#8 (comment) 中的提醒

使用 rootContainer 测试后是可以实现 AliveScope 注入需求的

那么这几天大概可以支持上了,以下是测通了的 demo

// src/app.tsx
import React from 'react';
import { Router } from 'umi';
import { renderRoutes } from '@umijs/renderer-react';
import { AliveScope } from 'react-activation';

function AliveScopeContainer({ children, history, ...renderRoutesProps }: any) {
  const useRouterComponent = children.type;

  useRouterComponent({ history, ...renderRoutesProps });

  return (
    <Router history={history}>
      <AliveScope>{renderRoutes(renderRoutesProps)}</AliveScope>
    </Router>
  );
}

export function rootContainer(container: any, clientProps: any) {
  return (
    <AliveScopeContainer {...clientProps}>{container}</AliveScopeContainer>
  );
}

@MinJieLiu @wangyinwei1 @lebron112

@CJY0208 CJY0208 mentioned this issue Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant