![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
immutable-lens
Advanced tools
React.PureComponent
, connect()
...$ npm i -S immutable-lens
import {createLens} from 'lib'
type State = {
user: {
name: string
age: number
}
}
const lens = createLens<State>()
////////////
// FOCUS //
//////////
const userLens = lens.focusOn('user')
const nameLens = userLens.focusOn('name')
const ageLens = lens.focusPath('user', 'age')
///////////
// READ //
/////////
const state: State = {
user: {
name: 'Bob',
age: 18
}
}
userLens.read(state) // {name: 'Bob', age: 18}
nameLens.read(state) // 'Bob'
/////////////
// UPDATE //
///////////
const setNameToJohn =
// THE FOUR LINES BELOW WILL ALL HAVE THE SAME EFFECT
nameLens.setValue('John')
nameLens.update(currentName => 'John')
userLens.setFieldValues({name: 'John'})
userLens.updateFields({name: (currentName) => 'John'})
setNameToJohn(state) // {user: {name: 'John', age: 18}}
pipeUpdaters()
import {createLens, pipeUpdaters} from 'lib'
type State = {
user: {
name: string
}
}
const state = {
user: {
name: 'Bob',
}
}
const nameLens = createLens<State>().focusPath('user', 'name')
const setNameToJohn = nameLens.setValue('John')
const uppercaseName = nameLens.update(name => name.toUpperCase())
const setNameToJOHN = pipeUpdaters(
setNameToJohn,
uppercaseName
)
const updatedState = setNameToJOHN(state) // {user: {name: 'JOHN', age: 18}}
defaultTo()
to avoid undefined values when reading or updating optional typesimport {createLens} from 'lib'
type State = {
loggedUser?: {
name: string
age: number
}
}
const state = {
// optional loggedUser field is undefined
}
const nameLens = createLens<State>()
.focusOn('loggedUser')
.defaultTo({name: 'Guest', age: 0})
.focusOn('name')
const name = nameLens.read(state) // 'Guest'
const setNameToBob = nameLens.setValue('Bob')
const updatedState = setNameToBob(state) // {user: {name: 'Bob', age: 0}}
import {Lens, createLens} from 'lib'
type Person = {
name: string
}
type State = {
friends: Person[]
}
const firstFriendLens = createLens<State>()
.focusOn('friends')
.focusIndex(0)
const firstFriend: Person | undefined = firstFriendLens.read({friends: []})
import {createLens, createComposedLens} from 'lib'
type State = {
todoList: string[]
}
const lens = createLens<State>()
const composedLens = createComposedLens<State>().withFields({
firstTodoItem: lens.focusOn('todoList').focusIndex(0)
})
const setImproveReadmeAsFirstTodoItem = composedLens.setFieldValues({firstTodoItem: 'Improve README'})
setImproveReadmeAsFirstTodoItem({todoList: []}) // {todoList: ['Improve README']}
getPath()
FAQs
Type-safe Lens API for immutable updates in complex data structures
The npm package immutable-lens receives a total of 0 weekly downloads. As such, immutable-lens popularity was classified as not popular.
We found that immutable-lens demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.