Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for mixed rendering#50

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Saegrov wants to merge4 commits intopreactjs:main
base:main
Choose a base branch
Loading
fromSaegrov:master

Conversation

@Saegrov
Copy link

Mixed rendering is a mode that works like shallow rendering, but where
you can specify a list of components you want to render even tho they
are deeply nested.

We have a use case where we are using shallow rendering and Cheerio for unit testing our Preact components. We are using a redux-connect like higher order component to connect some components to our global state.
When testing a component, that uses another component that is wrapped in a HOC, the shallow renderer stops at the HOC.

With mixed rendering we can white list components we want to render and test that the wrapped components are used correctly.

Mixed rendering is a mode that works like shallow rendering, but whereyou can specify a list of components you want to render even tho theyare deeply nested.
src/index.js Outdated
nodeName=getComponentName(nodeName);
if(opts.shallow&&
(inner||opts.renderRootComponent===false)&&
!opts.alwaysRenderedComponents.includes(componentName)){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Needs to useindexOf()!==-1 because this lib supports IE9+.

src/index.js Outdated
*@param {Array} alwaysRenderedComponentsList of components that should be rendered with shallow rendering
*@param {Object} [context={}]Optionally pass an initial context object through the render path.
*/
letmixedRender=(vnode,alwaysRenderedComponents=[],context)=>{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This file is size-constrained - would it be alright to add thealwaysRenderedComponents option, but not export another method (mixedRender)? That would keep things reasonably minimal.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sure! I'll update the PR.

@Saegrov
Copy link
Author

@developit I've updated the PR, but kept the unit tests in a separate file. Do you want me to move them as well?

@developit
Copy link
Member

Hi@Saegrov! Sorry for the delay - happy to have the unit tests in their own file. I think this should be good to merge, just need to check the file size.

Saegrov and Dev1OptimusTecno reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@developitdevelopitdevelopit left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@Saegrov@developit

[8]ページ先頭

©2009-2025 Movatter.jp