@travisWaithMair
non-traditional.dev
export function Hero(){
return (
<header className='hero'>
<h1>Assimilation Point</h1>
<p>The point of assimilation</p>
</header>
);
}
export function Hero({title, subtitle, bkgUrl}){
return (
<header className='hero' style={{background: `url("${bkgUrl}")`}}>
<h1>{title}</h1>
<p>{subtitle}</p>
</header>
);
}
export function Hero({title, subtitle, bkgUrl}){
let style = bkgUrl
? {background: `url("${bkgUrl}")`}
: undefined
return (
<header className='hero' style={style}>
{title && <h1>{title}</h1>}
{subtitle && <p>{subtitle}</p>}
</header>
);
}
export function Hero({title, subtitle, bkgUrl, className}){
const style = bkgUrl
? {background: `url("${bkgUrl}")`}
: undefined
const finalClassNames = ['hero', className].join(' ')
return (
<header className={finalClassNames} style={style}>
{title && <h1>{title}</h1>}
{subtitle && <p>{subtitle}</p>}
</header>
);
}
Tile Component
Tile Group
NavBar
List
ListGroup
function LandingPage(){
return(
<div>
{/*...*/}
<Hero
title='Assimilation Point'
subtitle="The Point of Assimilation"
/>
{/*...*/}
</div>
);
}
function LandingPage(){
return(
<div>
{/*...*/}
<Hero/>
{/*...*/}
</div>
);
}
function LandingPage(){
return(
<div>
{/*...*/}
<header className='hero'>
<h1>Assimilation Point</h1>
<p>The point of assimilation</p>
</header>
{/*...*/}
</div>
);
}
by Sebastian Markbage
(And it still will solve our problem if we just make this one little tweak)
react-clean-form is a package I wrote to abstract away wiring up state and change handlers to form inputs
<Form initialState={{userName: '',password: ''}}>
<input name='userName'/>
<input name='password'/>
</Form>
Under the hood, I recursively found every input and injected the change handler into the jsx
It provided no value over just using uncontrolled components
<form>
<input name='userName'/>
<input name='password'/>
</form>
Anything more complicated would most likely need a more powerful form abstraction than just simple state management
It's easy to fool ourselves into thinking we are working hard and being productive.
What we are really doing is delaying solving the hard problems we have now, by trying to solve the hypothetical problems of the future
[We tend to attach our self worth] to something that can be measured. A set of strict lint rules, a naming schema, a file structure, a lack of duplication.
Dan Abramov, overreated.io
It's easy to compensate for our own self-doubt by attributing our worth to how “clever” we can write our code.
i.e. Can we reuse this abstraction in multiple places in my app? If not, maybe it's not worth solving the problem generally (yet).
The Rule of Three