![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.
@composi/clone
Advanced tools
This function creates a deep clone of the provided object, which and be an array, an object, a Set, a Map, Date, etc. There is no need to use this with simple types like string or number. Clone objects is useful for state management where you don't want to directly manipulate the state.
It is possible to provide more than one object. In that case it will create a new object containing the combined deep clone of those objects. In this case order matters. Properties on earlier objects will be replaced by properties of later objects with the same properties.
Cloning works for arrays, objects, sets and maps. In the case of a weaksets and weakmaps, because of their nature as weak data structures, they are just copied as a reference to the original.
npm install --save-dev @composi/clone
You can clone an object with merge. Just pass in the object. The return object will be a clone:
import { clone } from '@composi/merge-objects'
const obj1 = {name: 'Joe', job: 'mechanic'}
const obj2 = clone(obj1)
obj1 === obj2 // returns false
import { clone } from '@composi/clone'
const obj1 = {name: 'Mary'}
const obj2 = {job: 'project manager'}
const person = clone(obj1, obj2)
// returns {name: 'Mary', job: 'project manager'}
If you want to clone an array, just pass it as the argument:
const arr1 = [{name: 'Joe'}, {name: 'Jane'}]
// Create clone of arr1:
const clonedArr1 = clone(arr1)
arr1[0].name = 'Joseph'
arr2[0].name // 'Joe'
You can use clone to merge any number of arrays together. This is a deep clone, which means you can use it safely with arrays of objects.
const arr1 = [{name: 'Joe'}, {name: 'Jane'}]
const arr2 = [{name: 'Mary'}, {name: 'Sam'}]
const arr3 = clone(arr1, arr2)
// arr3 equals [{name: 'Joe'}, {name: 'Jane'}, {name: 'Mary'}, {name: 'Sam'}])
arr1[0].name = 'Joseph' // [{name: 'Joseph'}, {name: 'Jane'}]
arr2[1].name = 'Samuel' // [{name: 'Mary'}, {name: 'Samuel'}]
// The above changes do not affect arr3:
// [{name: 'Joe'}, {name: 'Jane'}, {name: 'Mary'}, {name: 'Sam'}])
FAQs
Create a deep clone of an Object, Array, Set or Map. WeakSet
The npm package @composi/clone receives a total of 2 weekly downloads. As such, @composi/clone popularity was classified as not popular.
We found that @composi/clone 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.