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

React 0.74 - Update defaultProps to JavaScript default parameters. #661

Open
7 of 15 tasks
nd-gorm opened this issue May 15, 2024 · 72 comments
Open
7 of 15 tasks

React 0.74 - Update defaultProps to JavaScript default parameters. #661

nd-gorm opened this issue May 15, 2024 · 72 comments
Assignees
Labels
bug Crush'em all.

Comments

@nd-gorm
Copy link

nd-gorm commented May 15, 2024

Decision Table

  • My issue does not look like “The HTML attribute 'xxx' is ignored” (unless we claim support for it)
  • My issue does not look like “The HTML element <yyy> is not rendered”

Good Faith Declaration

Description

Hi it seems most components are setup to use TS defaultProp, which will be removed from function components.
I suppose this future error is present in all components using defaultProps.

React Native Information

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

`MemoizedTNodeRenderer: Support for defaultProps will be removed from memo components in a future major release. Use JavaScript default parameters instead.`

RNRH Version

6.3.4

Tested Platforms

  • Android
  • iOS
  • Web
  • MacOS
  • Windows

Reproduction Platforms

  • Android
  • iOS
  • Web
  • MacOS
  • Windows

Minimal, Reproducible Example

Run in a React Native project >= 0.74

Additional Notes

No response

@nd-gorm nd-gorm added the bug Crush'em all. label May 15, 2024
@Simba-Mupfunya
Copy link

same issue as @nd-gorm

@QuentinOber
Copy link

same issue as @nd-gorm .-)

@bruce-mec
Copy link

Same, after upgrading to react native 0.74

@ivanoikon
Copy link

Same issue here. But the question is: is this project still alive?

@yeezussniper
Copy link

I see attempts to fix this (f0c7e34). But they failed the test.
There are suspicions that the project is really abandoned :(

@djMax
Copy link

djMax commented May 19, 2024

I reached out with an offer to sponsor and have not heard back, so I have similar concerns. Perhaps time for a fork? Or perhaps @meliorence can add a maintainer.

@ba361006
Copy link

ba361006 commented May 21, 2024

same here, will show the warning as below

ERROR  Warning: TNodeChildrenRenderer: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.
ERROR  Warning: MemoizedTNodeRenderer: Support for defaultProps will be removed from memo components in a future major release. Use JavaScript default parameters instead.
ERROR  Warning: TRenderEngineProvider: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.

Version:

  • react-native-render-html: 6.3.4
  • react native: 0.74.1
  • react: 18.2.0

@yeezussniper
Copy link

@djMax and @ba361006
Eventually, I took this package and made it for myself inside my project

https://www.npmjs.com/package/htmlparser2-without-node-native

@djMax
Copy link

djMax commented May 21, 2024

But this doesn't do any of the translation to React components, no? That's the main magic bit of this module, IMHO.

@yeezussniper
Copy link

No, I just needed to display the users html in the View

@chriszs
Copy link

chriszs commented May 28, 2024

The CI step that failed when merging a fix in #658 was a linting step. Lint errors were fixed in #660, in which regarding the potential for a release the maintainer said, "I cannot promise anything, but will consider releasing when I find some time off." So, a fix may be released, but not on any definite timeline.

@linusrush
Copy link

Also looking forward to the fix release

@bytemtek
Copy link

same issue as @nd-gorm

@IvanMijic0
Copy link

Same issue as @nd-gorm

@Cube321
Copy link

Cube321 commented Jun 13, 2024

same issue as @nd-gorm

@bytemtek
Copy link

Is there any solution ?

@ivanoikon
Copy link

I solved switching to this library while waiting for a fix react-native-html-text-view.

@bytemtek
Copy link

I solved switching to this library while waiting for a fix react-native-html-text-view.

Thank you so much.

@QuentinOber
Copy link

I switched to react-native-htmlview and it's working fine so far; smooth transation.

@tmeduho
Copy link

tmeduho commented Jun 17, 2024

@jsamr any update?

@AronBe
Copy link

AronBe commented Jun 18, 2024

@skb1129 was the work done but not yet released?

f0c7e34

@tmeduho
Copy link

tmeduho commented Jun 24, 2024

@AronBe correct, see #660

@ycldz
Copy link

ycldz commented Jul 4, 2024

same issue

samijaber added a commit to BuilderIO/builder that referenced this issue Jul 5, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @builder.io/sdk-react-native@1.0.34

### Patch Changes

-   c787998: Fix: add `regeneratorRuntime` polyfill
- c787998: Fix: replace `react-native-render-html` with
`@builder.io/react-native-render-html` to remove `defaultProps` errors.
See <meliorence/react-native-render-html#661>
- c787998: Fix: disable async storage during static rendering (node.js)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@edritech93
Copy link

same issue for me, try switch to react-native-htmlview

@vinz-mehra
Copy link

@tmeduho So, do we have to wait now? or can we use this GitHub branch as a package on my project? Is there any workaround?

@TheRealMikeD
Copy link

Unfortunately, react-native-htmlview is missing a lot of features that this library has, which makes it a less than ideal replacement. At least, in my experience.

Hoping for a release soon!

@david-cahill
Copy link

Unfortunately the gitpkg approach results in a bunch of type declaration errors on my side. @jsamr Is there any chance you can publish 6.4.0 to npm to avoid these work-arounds?

@bruce-mec
Copy link

bruce-mec commented Sep 4, 2024

@david-cahill, I was able to use the patch suggested by @awlodarczyk above. This is how I got it to work.

Add the following as devDependencies

"patch-package": "^8.0.0" 
"postinstall-postinstall": "^2.1.0"

Create a "patches" folder in the root of your project
Copy the react-native-render-html+6.3.4.patch file into that folder.

Add postinstall to your scripts section in package.json

"scripts": {
    "postinstall": "patch-package"
    ......
}

You should now be able to run npm or yarn and get the following result.
** if you get an error about "patch....could not be parsed". It's likely a CRLF issue in the patch file sometimes caused by the windows file system if you're using windows. See here

% yarn
yarn install v1.22.22
[1/4] 🔍 Resolving packages...
success Already up-to-date.
$ patch-package
patch-package 8.0.0
Applying patches...
react-native-render-html@6.3.4 ✔
✨ Done in 0.52s.

@DanielKuhn
Copy link

Anyways, now that the fix is applied I get a new defaultProps-related warning from the table-plugin. I'll try to fix that next.

table-plugin fixed and PR opened: native-html/plugins#49

@DanielKuhn
Copy link

DanielKuhn commented Sep 4, 2024

Unfortunately the gitpkg approach results in a bunch of type declaration errors on my side. @jsamr Is there any chance you can publish 6.4.0 to npm to avoid these work-arounds?

The defaultProps-fix-commit has been added after 6.4.0, so please make that 6.4.1.

@david-cahill for which packages do you get type declaration errors? Have you tried resolving the dependencies to updated versions? In my case (after fixing the table-plugin) I had to add this in the package.json in my project:

"resolutions": {
    "@native-html/table-plugin": "https://gitpkg.now.sh/codevise/native-html-plugins/packages/table-plugin?88f1d56a4ace850d9cab7de585515d092b735121",
    "@native-html/plugins-core": "https://gitpkg.now.sh/codevise/native-html-plugins/packages/plugins-core?26870f796ad4a3ef5d728c460382dfc981e5b2c5"
}

@shawhu
Copy link

shawhu commented Sep 5, 2024

the patch works...but seriously, we need a fork and a new package

@david-cahill
Copy link

Unfortunately the gitpkg approach results in a bunch of type declaration errors on my side. @jsamr Is there any chance you can publish 6.4.0 to npm to avoid these work-arounds?

The defaultProps-fix-commit has been added after 6.4.0, so please make that 6.4.1.

@david-cahill for which packages do you get type declaration errors? Have you tried resolving the dependencies to updated versions? In my case (after fixing the table-plugin) I had to add this in the package.json in my project:

"resolutions": {
    "@native-html/table-plugin": "https://gitpkg.now.sh/codevise/native-html-plugins/packages/table-plugin?88f1d56a4ace850d9cab7de585515d092b735121",
    "@native-html/plugins-core": "https://gitpkg.now.sh/codevise/native-html-plugins/packages/plugins-core?26870f796ad4a3ef5d728c460382dfc981e5b2c5"
}

@DanielKuhn I receive type errors for the react-native-render-html lib. It looks like the react-native-render-html/lib folder is missing in node_modules (it's not built) so imports are not working correctly. I've also tried the resolutions but without success.

@iskifogl
Copy link

iskifogl commented Sep 6, 2024

patch is working for me as well but why nobody fork the project and create new packet or creater merge to this packet

@dezudas
Copy link

dezudas commented Sep 9, 2024

patch is working for me as well but why nobody fork the project and create new packet or creater merge to this packet

coz looks like everyone is hoping to update official release

@Mako-L
Copy link

Mako-L commented Sep 13, 2024

Will be seeing any push to main npm package soon? I would love to see this warning gone from the cli. Thank you in advance you guys do an awesome job.

@marcpope
Copy link

marcpope commented Sep 16, 2024

the original author is looking for someone to take this over:
Looking for maintainers #669
#669

@DorianMazur
Copy link
Collaborator

Don't worry folks, we will fix it soon

ardasnturk added a commit to smart-village-solutions/smart-village-app-app that referenced this issue Sep 27, 2024
- added patch shared on github to update package to prevent `defaultProps`
  warn in `react-native-render-html` package
  - meliorence/react-native-render-html#661 (comment)

SVA-1429
@haerim95
Copy link

haerim95 commented Oct 4, 2024

if someone needs, here is patch-package fixing issue

react-native-render-html+6.3.4.patch

thanks, bro.
This resolved the warning error.

@paultsimura

This comment was marked as off-topic.

@DorianMazur
Copy link
Collaborator

The issue isn't with merging, but with deployment. The fix for that is already merged. We've lost contact with the owners of this package, and together with @jsamr, we're planning to move it to a different repository.

@paultsimura

This comment was marked as off-topic.

@alexmartinezm

This comment was marked as off-topic.

@geeorgipehlianov1

This comment was marked as off-topic.

@kirasiris

This comment was marked as off-topic.

@kirasiris
Copy link

@ivanoikon @Cube321 Step 1: npm install --save-dev patch-package postinstall-postinstall Step 2: copy the 'react-native-render-html+6.3.4.patch' file to the patches folder that should exist in the route folder (ios, android, src, node_modules, patches) Step 3: add "scripts": { "postinstall": "patch-package" } if it is not there in package.json Step 4: npm install

post install should mean that when you build the patch is reapplied , hope this helps

@ivanoikon , thanks for the instructions. This was my first time implementing a "patch" and your instructions made it simple!

@jsamr
Copy link
Collaborator

jsamr commented Nov 3, 2024

I opened a ticket to track progress over here: #674

Note 1: pesting and requesting for this to happen quickly will not influence the process, I'm already doing the best I can, for free.

Note 2: you can suppress the warning with LogBox:

import { LogBox } from "react-native"

LogBox.ignoreLogs([
  /Support for defaultProps will be removed/,
]);

See the debugging basics official guide.

Note 3: this is a deprecation warning, the library still works.

@StonedTD
Copy link

StonedTD commented Nov 6, 2024

And this would suppress errors (since they are no more warnings) from appearing in console as well:

if (__DEV__) {
  const ignoreErrors = ["Support for defaultProps will be removed"];

  const error = console.error;
  console.error = (...arg) => {
    for (const error of ignoreErrors) if (arg[0].includes(error)) return;
    error(...arg);
  };

  LogBox.ignoreLogs(ignoreErrors);
}

@carlos-dubon
Copy link

https://www.npmjs.com/package/@builder.io/react-native-render-html this fork seems to have already fixed this.

@cupid20103

This comment was marked as off-topic.

@Th1nhNg0

This comment was marked as off-topic.

@meliorence meliorence locked as too heated and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Crush'em all.
Projects
None yet
Development

No branches or pull requests