Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 hours ago.
Improve this question
I have a react page where I want to render a few components at the same place. First of all I going to display loading section, most likely using the setTimeout() (to enlarge loading time just to make sure that people see it at least 2 seconds) but I don't know how to implement it in React. Then I want to render another component or components, Template is the same for them, but text should differ. So how can I do that? should I create a bunch of components, or I can just use one, and change its content?
I tried to use useState, but this is a little bit confusing for me
If your component has a text that you want to change depending on the API response, your text variable should have a conditional statement.
Let's assume that you want to check if an error occurred in order to deliver the proper message to the user.
Imagine that you are receiving the following response
const apiResponse = { message: 'Profile updated', status: 200, error: false }
You have two different approaches: use the api message or make a custom one. Let's do the second one and write a text for errors and one when everything worked out fine.
const noErrorText = 'Succesfully updated your profile!';
const errorText = 'An error occurred while updating your profile :(';
To render this text
const text = apiResponse.error ? errorText : noErrorText;
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Background
I have a live web dashboard for ticket numbers and their status updates. Each update and case number are in separate rows on this web page. To make this dashboard useful, I have to save it as offline HTML and import it into excel to copy one row of data like all case numbers.
Goal
How do I search for a matching string on a page and copy all to clipboard in separate lines? EG, all my case numbers match the first two digits like “12.......”
If I can manage to figure that out, I can make use of text in tools easier like Trello etc.
You could do something like this with Python:
import re
import requests
text = input("Enter text: ")
url = requests.get('https://stackoverflow.com/questions/69691849/what-is-the-best-method-to-copy-all-matching-text-from-a-web-page').text
page = re.findall(text, url)
for i in page:
print(i)
I don't think you'd be able to copy all the output, however you could just copy the output from command prompt. It's unclear what you are trying to fully achieve here.
Output:
Output with array ( print(page) ):
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
My question is about the standards of React and JSX. I am unsure how to formulate a page using React. Do I break down my page into components and render everything through JSX? Or is it a combination of HTML with rendered components strewn throughout?
I have been unable to find any succinct response to this question, but from what I have gathered, is that I break the webpage into only components.
It's a combination of HTML with rendered components strewn throughout. You can however also have only one master "component" to render the entire app and it's "sub" components rendered within.
I don't think the term component is the best one here but I get what you mean rather I think you mean React Element.
Generally it is preferred and easier to just use React Elements where you need React eg for a search bar and have everything else in HTML.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have built an Admin section where i can see all the contents from database in a table. everything is fine but if the database table has thousands of rows I have to scroll down very deep. is there any way I can make links like `1,2,3.Next the way google search results do? or is there any even better way?
Isn't is going to be something like:
if($(document).height>2000){
//what should i do?
}
Looks like you are using jquery. If you are going to implement everything on your own it may be time consuming - although it would be fun!
To save some time, there are quite a few plugins available to achieve this. Refer:
https://datatables.net/
http://www.jqueryscript.net/table/Client-side-HTML-Table-Pagination-Plugin-with-jQuery-Paging.html
Since you may have huge data you should be using server side pagination instead of client side. Here is another SO link which explains the difference between them : Pagination: Server Side or Client Side?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm (trying) to build an app based on boostrap/javascript/ and a nosql DB
a sort of small CRM/invoicing system
i need to show/hide button based on variable
for example for a quote, status could be "open", "lost" "win"
so on my quote details page when status of quote is open i want to show button
- win (who change status of quote id in db to win and copy quote to an order)
- lost (who change status of quote id in db)
but i want to hide button "Re-open" who change a cancel status to open
and so on for my different status..
so want i'm looking for is a way to collapse/hide some button depending of the status of my quote (i put the status of my quote in a variable called quoteStatus)
any suggestion will be welcome
thanks
jeebee
You can do something like that
if (quoteStatus==="value"){
document.getElementById("buttonId").style.display='none';
}
else{
document.getElementById("button").style.display='block';
}
this is just javascript, you could use jquery it will make it easier for you, so your code may look like that
if (quoteStatus==="value"){
$("#buttonId").hide();
}
else{
$("#buttonId").show();
}
To get more positive reactions to your question you have to show some research effort. This question is not useful in that mather that you havent actually showed us what you have tried, and the purpose of your functionality have possibly been asked and explained before? How to hide/show div based on variable using javascript. A div and a button is both elements.
Either way, as for your question, we need to know what you already have. The task in itself have several ways to be accomplished, and based on your existing code there could be a way to complete this task in a more correct manner than others.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Does anyone if/how to many JS errors affect the server? Does it affect page render?
I have different errors in different sites (and I will fix them) but does it affect anything?
Here is an example:
The javascript errors most likely won't affect the server, since Javascript is executed on client side.
When it comes to page render, javascript errors might break your page. Let's get for example angular single application, if there is javascript error, you're most likely to see nothing at all.
Errors such as undefined is not a function might be sign for passing value instead of callback. For example:
$.ajax("url.php", 32); // the second parameter must be callback/function
You must review your code and fix them, because these errors are clear sign that something in your application is not working.