Skip to content
This repository was archived by the owner on Apr 5, 2026. It is now read-only.

fix: remove deprecated defaultProps#277

Closed
iwfan wants to merge 1 commit into
romac:masterfrom
iwfan:fix_default_props
Closed

fix: remove deprecated defaultProps#277
iwfan wants to merge 1 commit into
romac:masterfrom
iwfan:fix_default_props

Conversation

@iwfan

@iwfan iwfan commented Jun 27, 2023

Copy link
Copy Markdown
Contributor

The defaultProps are being deprecated by React: reactjs/rfcs#107, react/react#16210

So remove defaultProps to avoid warnings from React

The `defaultProps` are being deprecated by React,
So remove defaultProps to avoid warnings from React
@iwfan
iwfan requested review from favna and romac as code owners June 27, 2023 13:55
@favna

favna commented Jun 29, 2023

Copy link
Copy Markdown
Collaborator

This is the wrong fix because you're no longer spreading in the default props. The proper fix is in #279

@favna favna closed this Jun 29, 2023
@iwfan

iwfan commented Jun 29, 2023

Copy link
Copy Markdown
Contributor Author

This is the wrong fix because you're no longer spreading in the default props. The proper fix is in #279

I do not think so. undefined also is a Nullish value in JavaScript. And the render function is perfectly capable of handling nullish value.

react-if/src/render.tsx

Lines 8 to 14 in c8c0866

export const render: FCWithImplicitChildren = (props) => {
if (typeof props.children === 'function') {
return <Fragment>{props.children()}</Fragment>;
}
return <Fragment>{props.children || null}</Fragment>;
};

So explicit declare null as default value of children seems redundant.

@favna

favna commented Jun 29, 2023

Copy link
Copy Markdown
Collaborator

null and undefined may both be nullish yes but they are still distinct. Furthermore, removing it entirely would be a breaking change (major version) whereas Kaname's change is merely a fix (patch version).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants