Skip to content

Instantly share code, notes, and snippets.

@barneycarroll
Last active September 2, 2022 14:37
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save barneycarroll/50295a5f36a45dd5bc772f5236bf5bbb to your computer and use it in GitHub Desktop.
Save barneycarroll/50295a5f36a45dd5bc772f5236bf5bbb to your computer and use it in GitHub Desktop.
React components are so fucking stupid, it's unbelievable. 3 months with this library version 15 and the glaring stupidity of the API just keeps coming in waves. Fixing some of this stuff – just for the sake of internal consistency – would have been so simple. The number of hoops you're required to jump through for trivial shit. Ugh.
const mounted = new WeakSet()
export default (component, displayName = component.displayName || component.name || 'React.Component') => {
const host = {
[displayName] : class extends React.Component {
constructor(){
this.state = {}
component.apply(this, arguments)
}
setState(partial, callback){
this.state = Object.assign({}, this.state, typeof partial === 'function' ? partial(this.state, this.props) : partial)
callback()
}
componentDidMount(){
this.setState = React.Component.prototype.setState
if(component.prototype.componentDidMount)
return component.prototype.componentDidMount.apply(this, arguments)
}
render(){
if(!component.prototype.render)
return this.props.children || []
const output = component.prototype.render.apply(this, arguments)
if(this.props.key && output.key === null)
output.key = key
}
}
}
return host[displayName];
}
@zlatnaspirala
Copy link

I really glad , i am not alone !

@pietrovismara
Copy link

Fuck this shit

@jakubkeller
Copy link

Vanilla JS, always...

@revskill10
Copy link

Why's this ?

@grenudi
Copy link

grenudi commented Feb 7, 2019

Ahhh... Fuck react twice . I hate a concept of fucking keys and data bindings or rather its absence. Slogan for react should be "wanna do it good ? Do it yourself! "/

@chriscoram123
Copy link

Fuck React, like my app, components, everything was running fine one night. But then the next day I wake up and all of a sudden nothing works, I got errors up the ass, and the documentation was ZERO help. What a fucking headache!

@clouedoc
Copy link

feel better now

@jerrellbryant
Copy link

I swear people sit at home and find ways to make things more complex than they need to be. I've been looking for away to access a DOM element from within two functional components for days! When this would've been done in a matter of seconds using document.getElementById() or document.querySelector() in JS. One article advising to use Ref and another saying it's bad practice to use Ref when accessing DOM elements. Which is it F*%k the right way or wrong way?!?!?!?

@chovyprognos
Copy link

React is pure trash. Use svelte

@Kwooda
Copy link

Kwooda commented May 10, 2022

React is the best evidence I have for the existence of evil

@clouedoc
Copy link

Hello, dear people who once commented this gist.
This is a friendly reminder to touch grass and drink water.

@barneycarroll
Copy link
Author

Don't touch grass, it's full of allergens.

@kedzior-io
Copy link

After working with React for 5 months my conclusion is:

React to the frontend is like PHP to the backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment