![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.
@app-masters/js-lib
Advanced tools
App Masters fetch class.
On the project setup, set the base url for your API and the necessary headers:
import { Http } from '@app-masters/js-lib';
...
const version = '1.0.0'; // get from package.json
const client = 'mobile'; // use 'mobile', 'admin' or 'web'
const env = 'development'; // use 'development', 'staging' or 'production'
const contentType = 'application/json';
const baseURL = 'http://localhost.com:3000';
const token = 'JWT-0000000000000'; // user's authentication token
Http.setup(version, client, env, contentType);
Http.setBaseURL(baseURL);
// after the authentication process
Http.setAuthorization(token);
Setting your headers like this, will give you this headers:
{
'Accept': 'application/json',
'Content-Type': 'application/json',
'mobile-version': '1.0.0',
'client': 'mobile',
'client-env': 'development',
'authorization': 'JWT-0000000000000'
}
Also, you can set a endpoint param. This param is a key/value that will overwrite the key with the value every time that it's found in a fetch call.
Examples:
Http.setEndpointParam('{_userID}', user.id);
Http.setEndpointParam('{_maxItems}', 5);
...
Http.get('/{_userID)');
Http.get('/items/?quantity={_maxItems}');
Anytime you can reset the headers to the default setup using Http.reset()
. This will reset your headers to what was set in Http.setup()
, removing the authorization
and all endpoint parameters.
The Http class have 4 main asynchronous methods for fetch: GET
, POST
, PUT
and DELETE
. After you set the base URL, you only need to pass the endpoint to fetch it.
Examples:
Http.get('/users').then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
// Using endpoint params
Http.get('/users/{_userID}').then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
Http.post('/users', {email: 'new@email.com'}).then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
// Full URLs ignore the baseURL set.
Http.post('http://localhost.com:3001/otherUsers', {email: 'new@email.com'}).then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
Http.put('/users/TH1S154U53R1D', {email: 'other@email.com'}).then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
Http.delete('/users/TH1S154U53R1D').then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
The status codes considered as success are: 200, 201 and 204 (on delete).
App Masters default app setup process.
Create a config file with defaults environments:
const envs = {};
envs.development = {
baseUrl: "http://localhost:3000/api",
uploadCareToken: "someXPTOtoken",
rollbarToken: "anotherCrazyToken"
};
envs.development_firebase = {
baseUrl: "https://remotehost-dev.herokuapp.com:3000/api",
uploadCareToken: "someXPTOtoken",
rollbarToken: "anotherCrazyToken"
};
envs.staging = {
baseUrl: "https://remotehost-staging.herokuapp.com:3000/api",
uploadCareToken: "someXPTOtoken",
rollbarToken: "anotherCrazyToken"
};
envs.production = {
baseUrl: "https://remotehost-prod.herokuapp.com:3000/api",
uploadCareToken: "someXPTOtoken",
rollbarToken: "anotherCrazyToken"
};
export default envs;
Import and call AppBootstrap:
import {store, storage} from './store';
import packag from '../package.json';
import envs from './config';
import {AppBootstrap} from '@app-masters/js-lib';
class App extends Component {
constructor () {
super();
try {
let callbacks = {
onMinVersionNotSatisfies: (version) => {
alert("Você deve atualizar sua versão agora! Por favor recarregue a página, se a mensagem continuar, limpe o cache do navegador.");
},
onNewVersion: (version) => {
alert('Bem vindo à nova versão!');
if (version === '0.2.0') {
// Some new version decision
}
},
onUncaughtError: (e) => {
if (e.message !== 'Failed to fetch') {
Rollbar.error(e);
alert("Houve um erro inesperado e os programadores responsáveis já foram avisados. \n\n Detalhes técnicos: " + e.message);
} else {
alert('Falha na conexāo');
}
}
};
// Bootstrap
AppBootstrap.setup("web", packag, envs, storage, callbacks);
} catch (e) {
alert("Houve um erro inesperado e os programadores responsáveis já foram avisados. \n\n Detalhes técnicos: " + e.message);
}
}
}
(callbacks are the same object used with AMActions.setup()).
importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-messaging.js');
firebase.initializeApp({
messagingSenderId: "1072711350296"
});
const Notifier = firebase.messaging();
Notifier.setBackgroundMessageHandler(function(payload) {
console.log('[firebase-messaging-sw.js] Received background message ', payload);
// Customize notification here
const notificationTitle = 'Background Message Title';
const notificationOptions = {
body: 'Background Message body.',
icon: '/firebase-logo.png'
};
return self.registration.showNotification(notificationTitle, notificationOptions);
});
</html>
<html>
<head>...</head>
<body>...</body>
<!-- add this script -->
<script src="https://www.gstatic.com/firebasejs/4.4.0/firebase.js"></script>
</html>
// initializing the firebase
firebase.initializeApp({
apiKey: '',
authDomain: '',
databaseURL: '',
projectId: '',
storageBucket: '',
messagingSenderId: ''
});
// lib setup
Notification.setup(firebase);
Notification.getToken((token) => console.log('It has the token! Notification should work fine', token));
Notification.handleMessage((message) => {console.log('message received -> ', message)}, console.error);
Check all changes on changelog.
FAQs
JS lib
We found that @app-masters/js-lib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.