Skip to content

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.

4 participants