-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 19 support #3985
React 19 support #3985
Conversation
🦋 Changeset detectedLatest commit: f1dbfeb The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
c4e02b1
to
b9da1d6
Compare
93a3ecd
to
92b9b2d
Compare
@@ -377,7 +377,7 @@ describe("is used to keep observable within component body", () => { | |||
}) | |||
expect(container.querySelector("span")!.innerHTML).toBe("22") | |||
expect(counterRender).toBe(2) | |||
expect(observerRender).toBe(3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React now renders the observer an extra time for some reason. The reaction only fires once though when the store mutates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these hooks are all basically anti-pattern anyway, so good enough :)
if (children && render) { | ||
console.error( | ||
"MobX Observer: Do not use children and render in the same time in `Observer`" | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
propTypes
removed in v19 so I've duped this inside the render body
@@ -49,7 +49,7 @@ test("computed properties react to props when using hooks", async () => { | |||
act(() => { | |||
jest.runAllTimers() | |||
}) | |||
expect(seen).toEqual(["parent", 0, "parent", 2]) | |||
expect(seen).toEqual(["parent", 0, "parent", 2, 2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}, [multiplier]) | ||
useEffect(() => setMultiplier(3), []) | ||
}, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: This pattern reoccures quite a few times in the test, might be nice to make a utility for it? (separate PR is fine if interested)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks so much for picking this up!
interface IObserverProps { | ||
children?(): React.ReactElement | null | ||
render?(): React.ReactElement | null | ||
} | ||
|
||
function ObserverComponent({ children, render }: IObserverProps) { | ||
if (children && render) { | ||
console.error( | ||
"MobX Observer: Do not use children and render in the same time in `Observer`" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: in the same time
-> at the same time
I must be missing something, but I am getting TypeScript errors when trying to use The errors relate to exports such as
Does anyone else see the same issue? (will keep looking into it in the meantime, but it seems to me that mobx-react is just relying on react type exports that no longer exist) |
Okay yeah, it looks like in
However, as seen, they were marked as deprecated. And then in So if |
One remaining error is in mobx-react, where it references import("react").Requireable and Validator, where those are now only in prop-types, not mobx-react: mobxjs/mobx#3985 (comment) Ignoring for now / until I get a response.
PropTypes are deprecated in MobX-react as well, so happy to accept a PR to
remove them.
…On Sun, Mar 9, 2025, 18:55 Stephen Wicklund ***@***.***> wrote:
Okay yeah, it looks like in @***@***.***, there were Requireable and
Validator exports:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/da70d4aee37cd531df1fc030c1e068fe51d3b5e9/types/react/v18/index.d.ts#L4149-L4157
/**
* @deprecated Use `Validator` from the ´prop-types` instead.
*/
type Validator<T> = PropTypes.Validator<T>;
/**
* @deprecated Use `Requireable` from the ´prop-types` instead.
*/
type Requireable<T> = PropTypes.Requireable<T>;
However, as seen, they were marked as deprecated.
And then in @***@***.***, they were removed (ctrl+f shows no results):
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts
So if Requireable and Validator are still needed by mobx-react, they need
to import from the prop-types package now, not react.
—
Reply to this email directly, view it on GitHub
<#3985 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBG2DFC6432BF537XHD2TSFB5AVCNFSM6AAAAABTJ3OL32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMBYHE4DOOJXGM>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: Venryx]*Venryx* left a comment (mobxjs/mobx#3985)
<#3985 (comment)>
Okay yeah, it looks like in @***@***.***, there were Requireable and
Validator exports:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/da70d4aee37cd531df1fc030c1e068fe51d3b5e9/types/react/v18/index.d.ts#L4149-L4157
/**
* @deprecated Use `Validator` from the ´prop-types` instead.
*/
type Validator<T> = PropTypes.Validator<T>;
/**
* @deprecated Use `Requireable` from the ´prop-types` instead.
*/
type Requireable<T> = PropTypes.Requireable<T>;
However, as seen, they were marked as deprecated.
And then in @***@***.***, they were removed (ctrl+f shows no results):
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts
So if Requireable and Validator are still needed by mobx-react, they need
to import from the prop-types package now, not react.
—
Reply to this email directly, view it on GitHub
<#3985 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBG2DFC6432BF537XHD2TSFB5AVCNFSM6AAAAABTJ3OL32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMBYHE4DOOJXGM>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
@mweststrate Okay, I've created a PR for it here: #4534 |
Code change checklist
UpdatedN/A/docs
. For new functionality, at leastAPI.md
should be updatedyarn mobx test:performance
)Note: before merging, I think I should also dup any
propType
checks inside render to be compatible across multiple React versions. I also intentionally haven't bumped the types forreact
andreact-dom
to keep the propTypes types such asValidator
,Requireable
etc.