-
Notifications
You must be signed in to change notification settings - Fork 894
feat: [UEPR-57] migrate to react v18 #9311
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
base: develop
Are you sure you want to change the base?
Conversation
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.
I picked a nit or two, but it's low-priority stuff. Kudos for getting through this!
👏👏👏
.github/workflows/ci-cd.yml
Outdated
# run unit tests in development mode to address error "act(...) is not supported in production builds of React" | ||
NODE_ENV=development JEST_JUNIT_OUTPUT_NAME=unit-jest-results.xml npm run test:unit:jest:unit -- --reporters=jest-junit |
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.
If test:unit:jest:unit
doesn't work outside of dev mode, would it make sense to move the NODE_ENV=development
part into package.json
? Something like:
"test:unit:jest:unit": "cross-env NODE_ENV=development jest ..."
const Avatar = props => ( | ||
const Avatar = ({ | ||
className, | ||
src = '//uploads.scratch.mit.edu/get_image/user/2584924_24x24.png?v=1438702210.96', |
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.
...lol. Thanks, Ray.
); | ||
} | ||
for (let i = 0; i < items.length; i++) { | ||
const thumbnails = items[i].thumbnails.map((item, j) => ( |
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.
😎
const SocialMessage = props => ( | ||
<props.as className={classNames('social-message', props.className)}> | ||
const SocialMessage = ({ | ||
as: Tag = 'li', |
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.
👍
messages = { | ||
'teacherbanner.greeting': 'Hi', | ||
'teacherbanner.subgreeting': 'Teacher Account', | ||
'teacherbanner.classesButton': 'My Classes', | ||
'teacherbanner.resourcesButton': 'Educator Resources', | ||
'teacherbanner.faqButton': 'Teacher Account FAQ' | ||
}, |
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.
Do you know if this complicates message scraping? I don't expect this change to make it worse, but it made me curious.
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.
Compared to the previous state or to something else? Speaking without full certainty, but I believe this change should lead to the same bundle outcome as the previous one - and these default values should be visible to scrapers.
expect(donateText.textContent).toEqual( | ||
'Scratch is a nonprofit that relies on donations to keep our platform free for all kids. Your gift of $5 will make a difference.' |
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.
Maybe a snapshot would be better?
.then(response => { | ||
expect(mockedValidateEmailRemotely).toHaveBeenCalledTimes(1); | ||
expect(response.valid).toBe(false); | ||
expect(response.errMsgId).toBe('general.error'); | ||
}) | ||
.then(() => { | ||
// make the same request a second time | ||
instance.validateEmailRemotelyWithCache('[email protected]') | ||
emailStepInstance.validateEmailRemotelyWithCache('[email protected]') | ||
.then(response => { | ||
expect(mockedValidateEmailRemotely).toHaveBeenCalledTimes(2); | ||
expect(response.valid).toBe(false); |
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.
Phew! That file was a lot ;)
|
||
useEffect(() => { | ||
if (hasRendered.current) { | ||
throw new Error('This component has been re-rendered!'); |
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.
😎
@@ -21,6 +21,7 @@ ENV | |||
|
|||
# Test | |||
/test/results/* | |||
/test/generated/generated-locales.js |
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.
Props for remembering to add this line!
src/components/grid/grid.jsx
Outdated
@@ -52,12 +63,19 @@ const Grid = props => { | |||
<Thumbnail | |||
href={href} | |||
key={key} | |||
loves={item.stats.loves} |
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.
Were those added on purpose?
StudioDescription.handleClickOutside = () => { | ||
const ref = useRef(null); | ||
|
||
useOnClickOutside(ref, () => { |
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.
Did we test this?
src/views/studio/studio-tab-nav.jsx
Outdated
const base = `/${studioPath}/${studioId}`; | ||
const classes = useCallback(({isActive}) => `nav-link ${isActive ? 'activated' : ''}`); |
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.
Should these be nav_link
and active
?
Resolves:
UEPR-57
Changes:
scratch-gui
the version is used. Updated studios routing. The previously used testing framework - Enzyme, won't be supported for react-18 and tests are migrated to React Testing Library (RTL). Most of the component tests rely on asserting props and state of the component, however RTL doesn't allow such assertions as what is intended to be tested by the library is only what the user would interact with. To bypass this there is a wrapper around the render method from RTL that searches the structure of the React element for the node that contains the props and state. We should discuss the approach before further updating the rest of the tests.DefaultProps
that will be deprecated in future releases for functional components.