airbnb / airbnb/react-sketchapp

Add TestRenderer.act callback function

Open
#528 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14.9k
Forks
797
PR merge metrics
No merged PRs in 30d

Description

_I am..._

| -------------------------------------------------------------------------------------------------
| Requesting a new feature
| -------------------------------------------------------------------------------------------------

**Proposal/Feature-request:**

Add callback to `render` function to run code inside `TestRenderer.act` function. https://github.com/airbnb/react-sketchapp/blob/b238e69c6f1e65ec6b1d8a908a91fbd9a8cc43a7/src/buildTree.ts#L96-L99

This should allow for Relay data fetching to occur before the component is rendered: https://relay.dev/docs/guides/testing-relay-components/#examples

I’ll work on hacking together a demo for this with a mock GraphQL Relay API; this could be expanded to having a full Relay example in this repo.

Contributor guide

Open the contributing guide

Research direction

Start at src/buildTree.ts around lines 96-99 and review how the render function is called. Check the React TestRenderer.act documentation and the linked Relay testing example; done means render accepts a callback that runs inside act so Relay data fetching can complete before rendering, with the behavior demonstrated using a mock Relay API.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.