Posts by Rafael Tavares • 4,528 points
139 posts
-
0
votes1
answer818
viewsA: React Navigation with Typescript
The problem occurs because the prop screenOptions.tabBarIcon is a function that receives { focused: boolean, color: string } and returns a React.Node, while its function is not returning anything.…
-
1
votes2
answers410
viewsA: API request error on localhost: "Possible Unhandled Promise Rejection"
The mistake Possible Unhandled Promise Rejection indicates that the Promise was rejected and you did not treat this rejection. To treat rejection, make use of the try and catch: async function…
-
1
votes1
answer260
viewsA: How to create and modify the same record with Sequelize?
Let’s get a few things straight first: The equivalent of INSERT in Sequelize is Modelo.create({ dados }). The UPDATE has two "equivalent" options in Sequelize: Modelo.update({ nome: "Novo Nome" }, {…
-
2
votes1
answer352
viewsA: React Navigation passing parameters to Brother Stack route
Navigators nested do not receive events from their parents Given the following structure: Home (Home) AllWorkouts (WorkoutStack) AllWorkouts (Workouts) WorkoutInfo (WorkoutInfo) Profile (Profile)…
-
0
votes3
answers83
viewsA: Reading Asyncstorage generates an infinite loop
Your access to AsyncStorage is in an infinite loop because you are performing this access in the body of its functional component, that is, with each rendering you are getting the data from the…
-
0
votes1
answer201
viewsA: How do I count records after a specific date in Sequelize?
The problem is that you are passing an invalid value as an object: data_hora: [Op.gte]: Date.now() The right thing would be data_hora: { [Op.gte]: Date.now() } If with Date.now() not working, use…
-
1
votes1
answer119
viewsA: I cannot render elements dynamically using foreach
.forEach() vs .map() When you want to display some kind of list on a component in React, use the Array.map(), because in addition to the desired function to be executed, a result is returned for…
-
2
votes2
answers365
viewsA: How to render asynchronous content in React Native?
An asynchronous function returns a Promise, then when using renderItens() you will be rendering this Promise (Object) and not its result (JSX), since it has not yet been solved. See What are…
-
2
votes1
answer493
viewsA: Query using Sequelize resulting in "column "id" does not exist" error
The field id is the default primary key used by Sequelize when none is reported in the model, which is your case (see method init of User). Migrations are used to create the structure of your…
-
1
votes1
answer41
viewsA: How to reuse a React component by displaying it differently?
If it makes sense that this button is part of Header and appear on just a few occasions, you can do: const Header = ({ withButton }) => { return ( <nav> <Link /> {withButton…
reactanswered Rafael Tavares 4,528 -
0
votes1
answer118
viewsA: Keyboard.Dismiss() function does not work
The element <View> does not own a property onPress. You can remove the <View> and use only the <ScrollView>, occupying the entire screen. The estate keyboardShouldPersistTaps of…
-
2
votes1
answer62
viewsA: Activity Access via Manisfest File - Android
Like the package (package="com.pokemon") is already specified in the tag <manifest>, you need to indicate only what is "missing". Note that the name should start with a point .: <activity…
-
0
votes1
answer76
viewsQ: How can I make regex recognize "partial results" in Javascript to mask an input?
I’m making a <input> with mask, formatting as user type. In this case, it is a CNPJ entry. A Regex to format the CNPJ would be /(\d{2})\.?(\d{3})\.?(\d{3})\/?(\d{4})-?(\d+)/g, but so it format…
-
3
votes1
answer588
viewsQ: How to start an object in Typescript without declaring all properties at once?
Taking into account the following interface: interface Usuario { nome: string; senha: string; email: string; } It is possible to declare an object "slowly" without creating a new type or interface…
-
3
votes1
answer229
viewsA: How to calculate the number of lines in a text in a <p> or <div> with Javascript?
Calculation of number of lines It is possible to calculate how many lines an element has by dividing its scrollHeight for his line-height and rounded up (if the result is 3.1 lines, actually the…
-
2
votes1
answer348
viewsA: SELECT sequelize
Your acesso is a model. Raw queries shall be made in a Sequelize. See the method documentation here and examples here. const [results, metadata] = await sequelize.query("/* ... */"); Remember that…
-
3
votes2
answers459
viewsA: What’s the "Never" type for?
never The guy never indicates that the function never returns something. That is, functions that generate an error or generate a loop have their return defined as never. Quoting the documentation,…
-
5
votes3
answers775
viewsQ: What are the ".d.ts" files?
Studying Typescript I noticed that there are files .d.ts and that it is possible to declare the guys there, but: What is the actual usefulness of files .d.ts? If I already declare the guys in the…
-
1
votes2
answers190
viewsA: Align icons and text on button
Your problem is the attributes width of .nav-item and .nav-button. If remove, resolves. This happened because you were using as a basis of calculation the value of --nav-size: 60px, representing the…
-
2
votes1
answer165
viewsA: Doubt about SEO. H1 in the header and article?
All references used in this answer are original in english, then all translations were performed freely. Notice this here not to need to warn whenever there is a quote. What are header tags for? It…
-
3
votes0
answers122
viewsQ: How to add/remove shadows from an element with "position: Sticky" as scrolled?
I made a table with the header and the last fixed column using position: sticky. To give an impression that it is above other columns/rows, I used box-shadow, but it gets weird to leave the…
-
1
votes1
answer314
viewsA: Equivalent to NPM I for React Native Expo
The command expo install can be used to install all the dependencies of a project. It involves the npm and the yarn so that you can ensure that the version of the Expo SDK and React Native community…
-
1
votes1
answer241
viewsA: Android Studio 4.0 incomparable Flutter Plugin
There are issues (#4136 and #4166) in the Flutter repository on the subject. Apparently, the message Plugins incompatibe with the new build found displayed by Android Studio is outdated, being a…
-
1
votes1
answer37
viewsA: When using tag div inside a parent element that has padding, the left padding is shown
What is happening is that the position: absolute makes you position the element according to the properties specifications top, right, bottom and left, then ends up "disregarding" this padding of…
-
0
votes1
answer53
viewsA: Array is empty outside the function scope even though it is declared in the global scope
The function fs.readFile() reads the contents of a file in a way asynchronous. Therefore, you are probably trying to read the contents of the arrays before you finish reading the file. In case you…
-
1
votes2
answers565
viewsA: Why doesn’t Firefox display WEBP images?
Updating the response, since Firefox now supports Webp. Support Firefox has image support .webp since January 2019, from version 65 (see the ad). It is possible to see all browsers that support…
-
1
votes1
answer37
viewsA: How to make a generation of text without scroll
You can try using the NeverScrollableScrollPhysics in the ListView.builder(): physics: const NeverScrollableScrollPhysics() According to documentation (free translation): Creates a scrolling physics…
-
0
votes2
answers217
viewsA: Nodejs and Mysql: Query 3 columns
The simplest way is to declare these attributes in the model as being unique, for example: const Usuario = sequelize.define("usuario", { email: { type: DataTypes.TEXT, allowNull: false, unique: true…
-
1
votes1
answer1428
viewsA: Decrypt password PASSWORD_HASH
According to the documentation of password_hash, in free translation: password_hash() creates a new password hash using a strong one-way hash algorithm. Emphasis on unidirectional. Generalizing, it…
phpanswered Rafael Tavares 4,528 -
3
votes1
answer2110
viewsA: I can’t create a project with create-React-app
Usually problems with the create-react-app occur when you have a version installed on your machine and then are trying to execute the command with an older version, as per documentation (free…
-
1
votes3
answers905
viewsA: Share state React Hooks
When the parent component is rendered, the child component is also rendered by default. You can use a logic not to update, but anyway, it makes sense to update when a prop change, which is what I…
-
0
votes1
answer219
viewsA: About the onActivityResult() method in Android Studio
It seems that you are confusing some things. A same Activity that uses startActivityForResult() should implement the method onActivityResult(). Initial Activity…
-
8
votes2
answers189
viewsA: Sum function with a large value returns a wrong result
It turns out that in Javascript a number is represented as Number. According to the specification (in free translation): Type Number has exactly 18437736874454810627 (i.e., 264 - 253 + 3) values…
-
1
votes1
answer63
viewsA: Perform OR operation between two models in Sequelize
I believe the problem with your query is that you didn’t put the Op.or as an array. Make the change and see if it works. If it doesn’t work, I found a example query you specify directly within the…
-
1
votes1
answer260
viewsA: Fatal error: Uncaught Error: Call to Undefined method mysqli_stmt::fetch_object()
In accordance with documentation, the signature of the method is mysqli_result::fetch_object. That is, it should be executed in the query result, not in the query itself. For example: if ($result =…
-
1
votes2
answers454
viewsA: Error when creating a bank with Sequelize
The problem is that you are not initiating Sequelize in the right way. Startup of Sequelize should be done as follows: const sequelize = new Sequelize('database', 'username', 'password', { options…
-
0
votes1
answer81
viewsQ: How to use plural with String Resources?
For internationalization, Android uses String Resources. How can I use this feature to use plural to avoid multiple "gambiarras" if's? Example: <string name="friends_none">Você não tem amigos…
-
1
votes1
answer47
viewsA: Low Resolution IONIC CAMERA
Looking at the documentation, you will see that targetWidth and targetHeight have the values specified in pixels. In your code: var options: CameraOptions = { quality: 100, sourceType: sourceType,…
-
1
votes1
answer827
viewsA: Typeerror: Trips.map is not a Function
The .map() is a method of Arrays, not Objects. Your response.data is an object, as shown by console.log(). If you want to get the Array with 5 objects containing id, nome_pet, descricao_pet etc. you…
-
1
votes1
answer121
viewsA: "onClick" and "onLongClick" functions are called with a single touch
According to the documentation of setOnLongClickListener, you need to return true an action is taken, false if it doesn’t happen. Passing by false, it is interpreted that the function was not…
-
2
votes2
answers532
viewsA: How to render html inside a functional component in React?
You can access through the prop children. For example: <Card cardHeader={cardTitle} cardBody={object}> <div className="card-close"></div> // Essa div é o "children" </Card>…
-
1
votes1
answer821
viewsA: Select in the Sequelize
To understand how the find from Sequelize, I’ll explain equivalent to your SQL code: SELECT c.colaboradorId, c.nome as nomeColaborador, g.nome as nomeCargo ,s.nome as nomeSetor FROM colaborador c,…
-
0
votes1
answer228
viewsA: Sequelize db:migrate error
Are you identifying the type as Selection, the correct is Sequelize Example: return queryInterface.createTable('users', { id: { type: Sequelize.INTEGER, primatyKey: true, autoIncrement: true,…
-
1
votes1
answer64
viewsA: Header fixed over subtitle by clicking on a content index anchor
I adapted an answer from Soen down below. The code has an explanation, but in short: When loading the page, check if it has a hash #. Example: site.com/#a. If it is, then we scroll a little above…
-
0
votes2
answers564
viewsA: Android Studio, file loss . jks
Updated answer: You can contact Google support to resolve this. Behold "Reset a lost or compromised private upload key": If you lose your private upload key or it is compromised, create a new one…
-
2
votes1
answer1938
viewsA: What’s the difference in having a JKS or a PKCS12 subscribing to my Android app?
JKS The JKS is an encrypted security file used to store a set of cryptographic keys or certificates in binary format and requires a password for the file to be opened. In this specific case, JKS is…
-
0
votes2
answers362
viewsA: Is it possible to block access to a middleware route?
You can create a function responsible for checking if the user is admin and use it as middleware, for example: const adminOnly = (req, res, next) => { // Verifique qual usuário está enviando o…
-
1
votes2
answers1950
viewsA: Close all the Activities
This response was made on the basis of Soen, but I added some details. First, let’s go back to the Activity initial (the one that starts next to your App): Intent intent = new…
-
2
votes1
answer861
viewsA: APK continuously crashes
You are looking for a layout element outside any of your Activity method Localizacao, causing the code to be executed before you set the layout with setContent: TextView statusLocation =…
-
2
votes2
answers63
viewsA: Condition other than in javascript
You can solve this by putting one else at the end of your code. This would make the following algorithm: Se a cidade for SAO PAULO Filial01 Se a cidade for RIO DE JANEIRO Filial02 ... Se não for…
javascriptanswered Rafael Tavares 4,528