Skip to content

Checkbox component throws warning when passing a string to title prop #3963

@malika-k

Description

@malika-k

Is there an existing issue for this?

  • I have searched the existing issues

Explain what you did

Use the Checkbox component and pass a string into the title prop (NOT a component).

Expected behavior

No warning should be thrown

Describe the bug

When doing this, the following warning is thrown:

Warning: TextElement: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.

Steps To Reproduce

Use the Checkbox component.
Pass a string into the title prop (instead of a component being passed in)

Example:
<Checkbox title={"String blah"} />

Note from Issue Creator

I've already investigated this bug and located where the warning is thrown

Location where warning is thrown in Checkbox component <--- when the title is a string, not a react component, it will create a rne Text component, and this is where tehe warning is thrown

Next Steps
I tried looking through the Text component but it is not leveraging defaultProps

Recommended Fix
I'd imagine a fix would look very similar to this PR which fixed the warning in the Dialog component: #3942

Screenshots

No response

Your Environment

`npx @rneui/envinfo`
  ```
    Output from `npx @rneui/envinfo` goes here.
  ```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions