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

[WIP]Feat Suspense #2307

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

[WIP]Feat Suspense #2307

wants to merge 11 commits into from

Conversation

chenjun1011
Copy link
Collaborator

@CLAassistant
Copy link

CLAassistant commented Jan 10, 2022

CLA assistant check
All committers have signed the CLA.

@carlisliu
Copy link
Contributor

This feat makes component's defaultProps invalid, reproduce code:

import { createElement, useEffect, useState, useRef, PureComponent, lazy, Suspense } from 'rax';
import Text from 'rax-text';

class TextView extends PureComponent {
  static defaultProps = {
    text: 'default text'
  };

  render() {
    return <div>
      <Text>{this.props.text || 'no default value'}</Text>
    </div>
  }
}

const LazyTextView = lazy(() => {
  return new Promise(resolve => {
    setTimeout(() => resolve({ default: TextView }), 2000);
  })
});

function Loading() {
  return <Text>loading...</Text>
}

export default function Defer() {
  return <div>
    <Suspense fallback={<Loading />}>
      <TextView />
      <LazyTextView />
    </Suspense>
  </div>
}

output:
default text
no default value

pending._result = thenable;
thenable.then((moduleObject) => {
if (payload._status === Pending) {
const defaultExport = moduleObject.default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const export = moduleObject.default || moduleObject; to support commonjs module?

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 this pull request may close these issues.

None yet

3 participants