docs: add prop merging ADR and mergeProps utility#8248
Conversation
|
joshblack
left a comment
There was a problem hiding this comment.
@copilot add the mergeProps.ts utility from: https://github.com/primer/react/pull/8168/changes#diff-b21bbbcb2674bcbc6f8e205e1c9223efea602c2abea46bb150c1d34b8ee06d07 and include tests for it. Also add an ADR for prop merging conventions for me with this decision. Highlight any scenarios that I should be aware of that aren't included already
Implemented in ba4584c. Added |
|
joshblack
left a comment
There was a problem hiding this comment.
@copilot I want to create an eslint rule for this behavior. To do this, let's:
- Create a local
@primer/eslint-configprivate package inpackages/* - In this, add a rule for the proposed merge props behavior
- This rule should look to see if props are spread on the outermost element and prefer using
mergeProps - This rule should not be enabled by default (eventually we will turn it on)
- Add a new migration report for this rule, reporting on number of places where it is failing that we would need to migrate
|
|
||
| The general rules do not cover every form of composition: | ||
|
|
||
| - **Refs are not composed.** Use `useMergedRefs` when both the component and |
There was a problem hiding this comment.
@copilot add a note that this will change in React 19 with refs passed as props
There was a problem hiding this comment.
Documented the React 19 ref-as-prop behavior and clarified that refs still require separate composition in 01b40e1.
c163b71 to
fc7d2ac
Compare
fc7d2ac to
1bc6f64
Compare
|
🤖 Lint and formatting issues have been automatically fixed and committed to this PR. |
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Add documentation for mergeProps utility function.
Treat undefined consumer handlers as absent so call sites can pass forwardable props directly to mergeProps. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: faa7e8da-1bd6-4c1c-831d-50b021ccc03b
Document how to forward destructured consumer props without rebuilding the second argument and prefer conventional internal prop values. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: faa7e8da-1bd6-4c1c-831d-50b021ccc03b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9541ca7f-0281-4223-a839-39d75393d922
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9541ca7f-0281-4223-a839-39d75393d922
Closes #
This PR adds ADR-025 and the foundation for using one prop-merging convention across Primer React. This entry owns the ADR, style guide guidance, and the internal
mergePropsutility and tests.Changelog
New
mergePropsutility and unit tests.Changed
Removed
Rollout strategy
This is internal architecture guidance and an unexported utility, so it has no public-facing impact.
Testing & Reviewing
Please review the ADR contract and merge semantics, especially class names, event handlers, styles, refs, and component-owned props.