Comments (5)
Have you all talked about how you want to go about this? Because I wonder if we want our mapWhitespaceProps()
function to ignore the incoming className
. Right now you have to do funky stuff like this to prevent the incoming value from being passed on:
delete props.className
const {className} = mapWhitespaceProps(props)
or, equally ugly:
const {className} = mapWhitespaceProps({...props, className: null})
Maybe we start with a function like lodash's omit()
and do it this way so that it's more explicit?
const {className} = mapWhitespaceProps(omit(props, ['className']))
Or we could introduce a more functional helper a la recompose
's mapProps()
combined with omit()
:
// props.js
import {compose, mapProps} from 'recompose'
import {omit} from 'lodash'
export const omitProps = (Component, keys) => props => <Component {...omit(keys, props)} />
// component.js
import {omitProps} from './props'
function Component(props) {
const {className} = mapWhitespaceProps(props)
return <div className={className}>...</div>
}
export default omitProps(Component, ['className'])
Any thoughts?
from react.
@shawnbot what about if we just do this (what you did in OcticonButton):
export default function OcticonButton({disabled, icon, label, onClick, size, ...rest}) {
const {className} = mapWhitespaceProps(rest)
from react.
🤦♀️ oh wait nevermind, I guess that would still pull in className since it'd be in rest
from react.
Yeah, I think there needs to be a more declarative way to either blacklist (before mapping) or whitelist (before passing along rest
values) certain props. I started on an approach for this but got distracted with first responder duties; I should be able to wrap up a demo tomorrow.
from react.
See also: #22
from react.
Related Issues (20)
- Deprecate and remove the input `contrast` prop HOT 3
- Disabled inputs look the same as enabled inputs in dark themes
- RelativeTime should render some kind of date in SSR HOT 1
- Dialog: Focus shifts unexpectedly on opening HOT 2
- NavList.Item active state should show up as bold, but doesn't. HOT 2
- Sub-component pattern cause error when used in React Server Components HOT 1
- Get ActionBar axe clean
- Type checking is too slow HOT 3
- Clean up custom element styled class names
- Underline nav: Doesn't work well on the smallest breakpoints HOT 11
- Release Tracking
- Setting `required` to `input` element within `TextInput` HOT 2
- TypeError: CSS.supports is not a function when running Jest tests HOT 2
- Active `NavList.Item` is incorrectly missing bold styling HOT 4
- The theme object inflates bundle size. HOT 1
- Release Tracking
- The `useAnchoredPosition` hook returns generic refs for Element, which always requires a type assertion by the user
- TreeView: Remove aria-describedby when leading and trailing visuals do not exist HOT 2
- Does the Primer Design System have card components or similar card-like components? HOT 1
- Release Tracking HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.