Welcome to this week's TWIL journey, where continuous growth is part of our DNA! Emily provides two insightful snippets to enhance your tech toolkit. First up, learn the quirks of Truthy Dictionary Keys and how Python determines the unique keys in a dictionary - a crucial piece of information for any Pythonista. Then, advance your understanding of React's setState method with SetState Argument for Previous State, grasping the use of prevState for more predictable state transitions. Whether it's a pythonic puzzle or a React revelation, these micro-learnings pave the way for smarter coding.

Truthy Dictionary Keys

Overriding:

>>> d = {'a': 0, 1: 'one', True: "true"}
>>> d
{'a': 0, 1: 'true'}

Accessing:

>>> d = {'a': 0, 1: 'one'}
>>> d
{'a': 0, 1: 'one'}
>>> d[True]
'one'

  • Python
Emily Morehouse's profile picture
Emily Morehouse

Cofounder, Director of Engineering


SetState Argument for Previous State

Previously, we would do something like:

const { num } = this.state
this.setState({
  num: num + 1,
})

setState can also take a function instead of an object, which provides us with the previous state as an argument:

this.setState(prevState => ({
  num: prevState.num + 1,
}))

// With parameter destruction
this.setState(({ num: prevNum }) => ({
  num: prevNum + 1,
}))

  • React
Emily Morehouse's profile picture
Emily Morehouse

Cofounder, Director of Engineering

Related Posts

A worn metal toolbox with the Python logo, representing the evolving toolkit for Python dependency management.
January 27, 2026 • Frank Valcarcel

Python Dependency Management in 2026

The Python dependency management ecosystem has finally matured. We break down uv, Poetry, and pip-tools with real benchmark data, PyPI download stats, and practical migration strategies.

Glowing teal React atom logo on a dark background featured image for a guide to every use directive, hook, and API in React 19.
January 7, 2025 • Marisa Gomez

The many uses for use in React 19

React 19’s relationship with the word use has reached the point where you could write an entire component and the only English word in it is use. We break down every flavor of use in React 19 and when to reach for each one.

Let's work together

Tell us about your project and how Cuttlesoft can help. Schedule a consultation with one of our experts today.

Contact Us