reactjs / reactjs/react.dev

Documentation error in the Render Props - Needs Interpolation

Open
#5,049 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

Hi Team,

I am trying to give a small correction in the documentation code of React under the topic Render Props.
This isn't such a big issue, but will definitely help newbies and must be addressed.

Under the Render Props concept in React documentation, in one of the examples, where a class component of Cat is created which returns an image, which is positioned absolutely. The position of that image is received through render props.

The received position coordinates are passed to the absolute positioned image. Now the problem is instead of using interpolation and adding units into it, the position coordinates values are directly given in the style object. Surprisingly the Img still moves respectively to the mouse pointer.

But I don't think giving the values without units is the right thing.
So, the below code should be changed from

From:
render() { const mouse = this.props.mouse; return ( <img src="/cat.jpg" style={{ position: 'absolute', left: mouse.x, top: mouse.y }} /> ); }
To:
render(){ const mouse = this.props.mouse; return ( <img src= './imgs/cat.jpg' style={{ left: ${mouse.x}px, top: ${mouse.y}px}} /> ) }

If my understanding is wrong, please correct me.

Much thanks!

Regards,
Hari prasad

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Render Props section of the React documentation and inspect the Cat example showing the mouse coordinates in the image style. Verify the coordinate styling against the surrounding documentation and React behavior, then update the example so the documented positioning is correct and consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.