# Fix "Support for defaultProps Will Be Removed from Function Components" After a React 18.3 Upgrade

Yes. An agent bumps React to 18.3, reproduces the defaultProps warning per component, moves each default into the parameters, keeps ESLint green and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/fix-defaultprops-will-be-removed-from-function-components-warning/react/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and finds every component the warning will name. In a Gatsby site like ivelum/job, `package.json` pins `react` and `react-dom` at `18.2.0` with Gatsby 4.24.0, `prop-types` 15.8.1 and `classnames` 2.3.2, the README asks for Node 15 or newer and Yarn 1, and `.eslintrc.json` extends `airbnb`. A search for `defaultProps` finds twelve files under `src/components/`, all function components: `Button.jsx`, `ExperienceRadioField.jsx`, `ExternalLink.jsx`, `Field.jsx`, `FieldLabel.jsx`, `FormErrorMessage.jsx`, `JobTextBlock.jsx`, `PageTitle.jsx`, `Row.jsx`, `SvgImage.jsx`, `layout/Layout.jsx` and `layout/Metadata.jsx`. `Row.jsx` is the smallest: `function Row({ children, gutterY })` with `Row.defaultProps = { gutterY: false }`; `Button.jsx` defaults `className`, `confettiAnimation`, `href`, `type` and `disabled`; `Field.jsx` defaults six props including `component: 'input'` and `componentProps: {}`.

Then it reproduces the warning without a full Gatsby build. The agent bundles `Row`, `Button` and `JobTextBlock` with esbuild, stubbing the `.module.scss` imports and Gatsby's `Link`, and renders them with `react-dom/server` in development mode. On React 18.2.0 the render is silent. On 18.3 it prints `Warning: Row: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.` and the same line for `JobTextBlock` and `Button`, each with its component stack, while the markup is identical. The warning is per component, once per process, so a page that renders all twelve prints twelve lines in development.

The fix is the one the warning asks for. `function Row({ children, gutterY })` becomes `function Row({ children, gutterY = false })` and the `Row.defaultProps` block is deleted; `Button` gets `className = ''`, `confettiAnimation = false`, `href = ''`, `type = ''` and `disabled = false` in its destructuring; `JobTextBlock` gets `title = null`; and the other nine files follow the same pattern, keeping each `propTypes` block as it is. Re-rendering the three bundled components on 18.3 prints nothing and produces the same markup as before, and the agent checks the same on React 19, where the output is also unchanged.

The part a plain rewrite misses is the linter. `eslint-config-airbnb` turns on `react/require-default-props`, which on the rewritten `Row` reports `propType "gutterY" is not required, but has no corresponding defaultProps declaration`; the airbnb config does not know about default parameters by itself. The agent sets the rule to `["error", { "functions": "defaultArguments" }]` in `.eslintrc.json`, after which the rewritten components pass and the old form fails with `Don't use defaultProps with function components`, so the lint now enforces the migration instead of fighting it.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Upgrade React and ReactDOM from 18.2 to the current 18.3 release and fix the \"Support for defaultProps will be removed from function components\" warning. Read package.json and the ESLint config, and list every file that assigns defaultProps, saying which are function components. Reproduce the warning by rendering a few of them with react-dom/server on 18.3, quoting one warning with its component name. Move each function component's defaults into default values in its parameter destructuring, delete the defaultProps block, and leave propTypes and class components alone. Render the same components again to show the warning is gone and the markup unchanged. Run ESLint; if the airbnb require-default-props rule rejects default parameters, configure it for them rather than disabling it. Open a pull request that quotes the before and after.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request touching the twelve component files, `.eslintrc.json`, `package.json` and `yarn.lock`: every `defaultProps` block on a function component replaced by default parameter values, the `react/require-default-props` rule configured for `defaultArguments`, and React moved to 18.3. The description quotes the warning for `Row` from the 18.3 render, the silent render after the change with its identical markup, and the ESLint result before and after the rule change.

A reviewer checks a few defaults that are not literals: an object or array default like `componentProps: {}` in `Field.jsx` is now created per render rather than shared, which is harmless unless something compared it by identity, and the pull request lists those cases. The run's record holds each render and lint run with its full output, so the twelve warnings and the clean run can be opened rather than taken on trust.

## Run it on every Monday morning

Add an automation to the Project with this prompt and a `schedule` trigger, `cron` set to `0 9 * * 1` in your `timezone`. Each Monday one run bumps React, renders the components that changed and opens one pull request on its own branch; a week where a new warning has no mechanical fix ends `needs_review` with the warning attached, and a week already on the current release opens nothing.

The same body works from your own code with `POST /o/{org}/sessions` and an API key when a dependency bot's React bump turns red; the key's `webhook_url` receives `run.completed` or `run.failed` with the session URL and the pull request when the run ends.

## Why run it on Rush?

This warning only prints in development, so a laptop sees it as console noise and production never sees it at all, right up to the release that removes the feature. The agent renders the components on the old and new React in its sandbox, keeps each render and its output in the run's record, and the pull request shows the warning appearing at 18.3 and disappearing after the rewrite with the markup unchanged.

The rewrite is twelve files of the same edit, and the trap is the lint config that will reject all twelve. Because the agent runs ESLint with the repository's own airbnb config, it finds that `require-default-props` needs the `defaultArguments` option and changes the rule once, instead of leaving a green render and a red CI.

## Frequently asked questions

### Why is defaultProps on function components going away?

React 18.3 warns because the feature is being removed for function components, where a default parameter in the destructuring does the same job without a second object to keep in sync. Class components keep `defaultProps`, and the agent leaves them alone.

### Does the markup change?

Not when the defaults are the same values. The agent renders the components before and after with `react-dom/server` and compares the output; the pull request includes the two strings. A default that is an object or array is now a fresh value on each render, which it lists separately.

### What about the ESLint rule?

The airbnb config enables `react/require-default-props` in its default mode, which still expects a `defaultProps` block and reports every rewritten component. The `{ "functions": "defaultArguments" }` option makes it require default parameters instead and reject `defaultProps` on function components, so the rule enforces the new form.

### Will it also move to React 19?

Not in this change. The prompt asks for 18.3, the release that adds the warning without changing behavior, so the defaultProps rewrite ships on its own. A React 19 upgrade is a separate run with its own list of changes.

## More React jobs

- [Fix Flaky Tests in a React App](https://getrush.ai/run/fix-flaky-tests/react/)
- [Fix React Exceptions From PostHog Error Tracking](https://getrush.ai/run/fix-posthog-exceptions/react/)
- [Fix "ReactDOM.render is no longer supported in React 18. Use createRoot instead"](https://getrush.ai/run/fix-reactdom-render-no-longer-supported/react/)

## More jobs like this: Upgrade dependencies weekly

- [Fix the delim_whitespace Keyword in pd.read_csv Is Deprecated Warning](https://getrush.ai/run/fix-delim-whitespace-keyword-is-deprecated-warning/pandas/)
- [Fix "AttributeError: 'Engine' object has no attribute 'execute'" in SQLAlchemy 2.0](https://getrush.ai/run/fix-engine-object-has-no-attribute-execute/sqlalchemy/)
- [Fix "Error [ERR_REQUIRE_ESM]: require() of ES Module" After Upgrading chalk](https://getrush.ai/run/fix-err-require-esm/chalk/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
