Engineering

Our engineering is underpinned by principles that celebrate both the integrity of code and the ambition to innovate. This manifesto champions excellence, advocates for the adoption of cutting-edge technologies, and fosters an environment of continuous intellectual growth.

State & Props

Initializing State

We no longer use the constructor and instead define State property directly, like so,

class UserGreeting extends Component { state = { name: 'John' } render() { return <h1 className='name'>{this.state.name}</h1> } } export default UserGreeting

For Data Fetching use cases, State can be initialized inside thecomponentDidMount lifecycle.

hydrateState = () => fetch('https://api.example.com/products') .then(response => response.json()) .then(data => this.setState({data}) .catch(error => console.error(error)) componentDidMount () { this.hydrateState() }

Props

Only provide components with the necessary Props.

class UserGreeting extends Component { state = { user: { name: 'John', email: 'john@site.com', age: 28 } } render() { // Destructure nested object props for better readability const user = this.state.user return ( <div> <NameTag name={user.name} /> // Instead of <NameTag user={user} /> <EmailLink email={user.email} /> <h4>{user.age}</h4> </div> ) } } export default UserGreeting

Reference

• The constructor is dead, long live the constructor! (hackernoon.com): https://hackernoon.com/the-constructor-is-dead-long-live-the-constructor-c10871bea599

Next: Design Playbook

Connect.

Mashup Garage, a premier software development team, specialises in crafting exceptional products for startups and enterprises. With expertise in React, Elixir/Phoenix, and Ruby on Rails, we deliver solutions that meet your unique needs. Our mission is to bring value backed by decades of technical expertise and global co-founding experience.

What do you need help with?

Build a project

Build a team

Consult

Speak to someone

Expect a guaranteed response from us in 1-2 business days.

United Kingdom

London

Islington, London

+44 738 777 3405

LDN

Philippines

Manila

3F Topy IV Building, 3 Economia Road, Bagumbayan, Quezon City, 1110

+63 917 3084089

MNL