Best Coding Patterns regarding modifying data in children in VueJS

we are currently trying to add an attribute to a prop object in a child component in VueJS. We have 2 options:

  1. Storing the props in a data object containing all the required attributes and modifying it by calling the child’s

setValue(item, value)

public method from the parent.

  1. Emitting an event from the child asking the parent to add the required attribute to the prop object using

this.$set()

and not create any data object.

  1. Any other method?

What is the best practice in this case?

How to search through dynamic table vuejs?

So I am creating tables in vue using loops, i.e. anyone can upload a table and view it.

<el-table :data="filtered"  border style="width: 100%" height="500" @selection-change="handleSelectionChange" @header-click="contextmenu">
  <el-table-column type="selection" width="55"/>
  <el-table-column  fixed v-for="col in columns" :prop="col.field" :label="col.field" :key="col.field"/>
  <el-table-column>
    <template #header>
        <el-input v-model="searchQuery" size="small" placeholder="Type to search" />
      </template>
      <template #default="scope">
        <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">Delete</el-button>
      </template>
    </el-table-column>
  
  </el-table>
  <el-button type="warning" round v-on:click="getdata(selected_data,source)">Update-Data</el-button>
</div>

I and trying to implement a search feature that is dynamic, i.e. it can search through all the columns of any table uploaded by user.
I saw some solutions online but they are for fixed tables.
I also tried writing a loop and returning the data

computed: {
    filtered (){
      if(this.searchQuery){
      return this.d.filter((item)=>{
        for(let i=0;i<this.columns.length;i++){
          const x=this.columns[0].field //I have an array columns which has all the columns inside 
                                          //of it in a dictionary
          console.log(item.x.startsWith(this.searchQuery)) //this gives an error *Cannot read 
                                                             //properties of undefined (reading 
                                                             //'startsWith')*
        }
        return item.Name.startsWith(this.searchQuery); // and this line works perfectly fine, if I  
                                                          //the table has a column named **Name**
      })
      }else{
        return this.d; //d is the data array
      }
    }
  }

Is there a way I can search through all the columns of any table uploaded by the user?
Any suggestions are greatly appreciated.

How to rearrange an array

I have an array that contains 4 elements I want to take any element randomly and push it to the new array and remove it then make this cycle to the end of the array I have made it but there is a problem it is rendering 2 elements only in the new array and they might have the same valuevas

enter image description here

Create a web interface for a Python numerical simulation code (and where to host it)

I need to create a web interface for a Python numerical simulation code, and host both (interface and python code).
When a user will run a simulation, it could take hours, or even days for the simulation to finish (and of course it has to run many simulations in parallel for multiple users).

So I am wondering what are my options to achieve this.

Use a frontend framework for the interface and a web server for the python code ?
Or use a framework like Django (which I never used)

And also where can I host such a code (the Python code), is there any provider like AWS or GCP which have a good option for it ?

Better Discord Show Alert If Pinged

I was wondering if there was a way to show an alert using a better discord plugin if you receive a ping or @ from any user?

BdApi.alert("Pinged", "test");

This is the alert I would want to show, whenever u receive a ping or @ from someone.

React Native modal not updating state components

I have a component here called Starters:

  const Starters = ({item}) => {
    const handleAdd = (data) => {
      setHomeData(data);
      showHomeModal()
    };

    const data = {
      Name: item.title,
      Stack: item.stack,
      ScheduleName: item.subtitle,
      Track: true,
      TrackString: "true",
    }

    return (
      <Card
        style={{
          marginRight: 10,
          marginBottom: 6
        }}
      >
        <Card.Title
          title={item.title}
          subtitle={`Schedule: ${item.subtitle}`}
          right={() =>
            <IconButton
              icon="plus-circle"
              color="#5F9DA5"
              onPress={() => handleAdd(data)}
            />
          }
          rightStyle={{
            marginBottom: 22
          }}
        />
        <Card.Content>
            {Object.entries(item.stack.slice(0,3)).map(item => (
              <View key={uuidv4()} style={{flexDirection: "row"}}>
                <Text
                  key={uuidv4()}
                  style={{
                    fontSize: 12,
                    marginVertical: -3
                  }}
                >
                  {item[1].substance}: {item[1].amount}{item[1].measure}{"n"}
                </Text>
              </View>
            ))}
        </Card.Content>
      </Card>
    )
  }

The item of the component is seen as follows:

  const itemData = {  
    "Vits": {
      title: "Morning Essentials",
      subtitle: "Everyday",
      stack: [
        {
          substance: "Omega3",
          amount: "3900",
          measure: "mg",
          id: uuidv4()
        },
        {
          substance: "B12",
          amount: "25",
          measure: "mg",
          id: uuidv4()
        },
        {
          substance: "B-complex",
          amount: "2",
          measure: "Tablets",
          id: uuidv4()
        }
      ]
    },
    "Vits2": {
      title: "Evening Essentials",
      subtitle: "Everyday",
      stack: [
        {
          substance: "Vitamin C",
          amount: "500",
          measure: "mg",
          id: uuidv4()
        },
        {
          substance: "Calcium Citrate",
          amount: "500",
          measure: "mg",
          id: uuidv4()
        },
        {
          substance: "D3",
          amount: "16000",
          measure: "IU",
          id: uuidv4()
        },
        {
          substance: "Magnesium",
          amount: "80",
          measure: "mg",
          id: uuidv4()
        },
        {
          substance: "Zinc",
          amount: "10",
          measure: "mg",
          id: uuidv4()
        },
        {
          substance: "Multi-vitamin",
          amount: "1",
          measure: "Tablets",
          id: uuidv4()
        }
      ]
    }
  }

I render the Starters components as follows:

...
      <ScrollView
        horizontal={true}
        style={{
          padding: 6,
          paddingHorizontal: 10
        }}
      >
        <Starters
          item={itemData["Vits"]}
        />
        <Starters
          item={itemData["Vits2"]}
        />
      </ScrollView>
...

As seen above, my handleAdd function sets a homeData const in a parent component by passing down the setHomeData function and calling it in the onPress of my Card‘s IconButton. showHomeModal in this function is also from the parent component and sets the value to true to display the modal.

This does two things:

  1. Set the homeData
  2. Call the function to open a modal with showHomeModal

The actual modal being called is supposed to display some of the data from itemData after the user presses the IconButton. I have some “filler” data to avoid any undefined errors in the modal like such:

const [homeData,setHomeData] = useState({
    "ScheduleName": "Everyday",
    "Stack": [
      {
        "amount": "3900",
        "measure": "mg",
        "substance": "Omega3",
        id: "7846365hjbvbert674t"
      },
      {
        "amount": "25",
        "measure": "mg",
        "substance": "B12",
        id: "8r76438hjvfguy"
      },
      {
        "amount": "2",
        "measure": "Tablets",
        "substance": "B-complex",
        id: "783657345634hgvbhjvh"
      },
    ],
    "Name": "Example",
    "Track": false,
    "TrackString": "false",
    "StartDate": new Date().toISOString()
  });

My modal is passed the homeData and this data is rendered in the modal.

...
      <Portal>
        <HomeStarterModal
          homeModalVisible={homeModalVisible}
          homeData={homeData}
          hideHomeModal={hideHomeModal}
        />
      </Portal>
...

This is where my problem arises. When the modal opens, instead of showing me data of the current homeData, I’m getting the original “filler” data being displayed. For example:

const HomeStarterModal = ({
  homeModalVisible,
  homeData,
  hideHomeModal
}) => {
  const [formState,setFormState] = useState(homeData["Stack"]);
  const [protocol,setProtocol] = useState(homeData["ScheduleName"]);
  const [name,setName] = useState(homeData["Name"]);

  return (
       ...
        <View style={MainStyles.col}>
          <Subheading>1. Give it a name</Subheading>
          <TextInput
            label="Name"
            value={name}
            onChangeText={name => setName(name)}
            mode="outlined"
          />
        </View>
       ...

This is returning an input with “Example” as opposed to what homeData‘s Name prop should be. When I log what the homeData is from the modal by doing something like this:

const HomeStarterModal = ({
  homeModalVisible,
  homeData,
  hideHomeModal
}) => {
  const [formState,setFormState] = useState(homeData["Stack"]);
  const [protocol,setProtocol] = useState(homeData["ScheduleName"]);
  const [name,setName] = useState(homeData["Name"]);

  return (
       ...
        <View style={MainStyles.col}>
          <Subheading>1. Give it a name</Subheading>
          <TextInput
            label="Name"
            value={name}
            onChangeText={name => setName(name)}
            mode="outlined"
          />
          <Button
            onPress={() => console.log(homeData)}
          >
            log
          </Button>
        </View>
       ...

This log output is the correct homeData object that corresponds to the correct Starters data that the user selects. So my question is this: How can I get the data to be correctly displayed in my modal? Why are useState hooks in my modal not detecting the change from the homeData variable being passed to my modal?

Why the button stays always hidden?

<div class="app__land-bottom" v-if="isVisible">
  <a href="#projects">
    <img ref="arrowRef" id="arrow" src="./../assets/down.png" alt srcset />
  </a>
</div>

In Vue3 setup isn’t working, but on Vue2 is working the following solution for not displaying a button based on scrolling.

VUE3
<script setup>
import { ref, onMounted, onUnmounted } from "vue";

let isVisible = ref(false);

onMounted(() => {
  window.addEventListener("scroll", () => {
    hideArrow();
  });
});

onUnmounted(() => {
  window.removeEventListener("scroll", () => {
    hideArrow();
  });
});

const hideArrow = () => {
  const currentScroll = window.pageYOffset;
  if (currentScroll > 100) {
    isVisible = false;
  } 
  else if (currentScroll < 100) {
    isVisible = true;
  }
}
</script>
VUE2
<script>
export default {
  created() {
    window.addEventListener('scroll', this.hideArrow)
  },
  data() {
    return {
      isVisible: false, 
    }
  },
  methods: {
    hideArrow() {
      const currentScroll = window.pageYOffset;
      if (currentScroll > 100) {
        this.isVisible = false;
      } else if (currentScroll < 100) {
        this.isVisible = true;
      }
    },
  },
}
</script>

In vue2 the solution is working but on Vue3, not. Any suggestions?
I don’t understand exactly where the problem is? It would be helpful an answer.

why populate method blocks user info come?

I am trying to add follow/unfollow functionality to my app. when I add populate methods in userById it stops showing user info on profile pages. what can I do?

 exports.userById = (req, res, next, id)=>{
 User.findById(id)
 .populate('following', '_id username')
 .populate('followers', '_id username')

 .exec((err,user)=>{
     if(err || !user){
        return res.status(400).json({
             error: "user not found"
         })
     }
     req.profile=user 
     next()
 })

}

JavaScript and ReactNative

I have the following code sequence where some calendar data is checked with scheduling data.
The problem is that if there are 2 or more appointments, I get the rest duplicated, tripled. How can I change?
{ programari.map(val=>{

         if(val.date==selectedDate ){
                                
                if(val.hour==hour){
                  [enter image description here][1]return(
        
                                   <RadioButton.Item label={hour} value={hour} disabled={true} style={{backgroundColor:'red',opacity:0.4}} />
                                   )  
                                }        
                                else return  <RadioButton.Item label={hour} value={hour} disabled={false} style={{backgroundColor:'green',opacity:0.4}} />
                              }
                             
                    
                            })}

JS SyntaxError: Unexpected reserved word

Hello i’m currently working on a project where I have these two:

async function getCoinQuote(inputMint, outputMint, amount) {
let res = got
    .get(
        `https://quote-api.jup.ag/v1/quote?outputMint=${outputMint}&inputMint=${inputMint}&amount=${amount}&slippage=${SLIPPAGE}`
    )
    .json();
return res;
}

//In my main 
const buyRoute = await getCoinQuote(
        QUOTE_MINT,
        ASSET_MINT,
        initial
    ).then((res) => {
        return res.data[0];
    });

The thing I don’t understand is that this works when im running it on my mac, but whenever I put it on my Ubuntu machine I get this error :

            const buyRoute = await getCoinQuote(
                         ^^^^^

SyntaxError: Unexpected reserved word
    at Loader.moduleStrategy (internal/modules/esm/translators.js:140:18)
    at async link (internal/modules/esm/module_job.js:42:21)