Questions tagged [ref]

The ref keyword causes an argument to be passed by reference, not by value. The effect of passing by reference is that any change to the parameter in the method is reflected in the underlying argument variable in the calling method. The value of a reference parameter is always the same as the value of the underlying argument variable.

Filter by
Sorted by
Tagged with
2 votes
0 answers
23 views

2 different refs of the same component with each other react native video

I have a project that I developed with react native and in which I use the react-native-video library. We use the same video component in 2 different navigation(i mean screen). (I'll abbreviate these ...
  • 2,091
0 votes
1 answer
32 views

How do I combine refs in Vue.js with a ternary expression?

Consider the code snippet below: const salesFilter = computed(() => { return Object.values(dataset.value).filter((item) => item.category==="Sales") }) const salesTotalTwo = ref((...
2 votes
1 answer
13 views

How to clearInterval if the setInterval was called via ref from a parent component in vue2?

I have a parent in which I call a function startTimer() with a ref and I want to stop this Timer directly within the child component but that doesn't work. I read somewhere that arrow functions in the ...
0 votes
1 answer
31 views

Entity Framework duplicating records when calling SaveChanges

I am using Entity Framework 6: JObject jCardRecord = JObject.FromObject(record, _ignoreCircularReferenceJsonSerializer); JObject jProduct = JObject.FromObject(product, ...
0 votes
0 answers
55 views

Ref value showing undefined inside an event handler function in react js

I am new to react and I am tring to access the amount value using amountInputRef.current.value for my food app inside submitHandler function but it shows as undefined when I try to add the items in ...
0 votes
1 answer
38 views

ref doesnt set value to variable in useEffect

I've been doing some React crash course and got in a lot of problems. To start with, observer.current.observe(ElemenentIGotWithRef.current) wasn't working in useEffect, because for some reasons the ...
0 votes
1 answer
29 views

React Ref with Class Component issue

Child Component Parent Component Here I get an issue that My parent Component isn't able to access child Component ref when I click button. It calls the method clickHandler by clicking on button but ...
0 votes
2 answers
63 views

Passing reference_wrapper instead of a reference into a std::thread and into std::vector [closed]

Reference_wrapper is a class wrapper around a pointer. I miss some basic information on the motivation, why reference_wrapper was introduced and Im trying to find it out with the following questions: ...
-1 votes
1 answer
32 views

How to render the function inside addEventListener load in reactjs or nextjs?

const Test = () => { const [ reload , setReload ] = useState('') useEffect(() => { console.log("useEffect Reloded"); document.getElementById( "img" )!...
1 vote
1 answer
58 views

What happens to a std:.reference_wrapper if the reference used to create it goes out of scope?

What happens to a std::reference_wrapper if the reference used to create it goes out of scope? Can it still still provide access to the underlying object (which would still exist), or would it be ...
  • 13
1 vote
1 answer
43 views

Typing the Ref Composition API Vue

how could I type correctly my Ref firstName as string? There are 2 errors underlined, in the template - {{ firstName }}, and in the script - const firstName = ref('') as String. I suppose it has to do ...
2 votes
1 answer
35 views

Dotnet Reflection: Calling Invoke on MethodInfo With 'out' Parameter from F#

I retrieve a TryParse method for a given type like this: open System.Reflection let stringParser<'T> = typeof<'T>.GetMember("TryParse") |> Seq.cast<MethodBase> ...
0 votes
2 answers
327 views

Is is possible to call watch() on an input ref in Vue 3 to watch the input's value attribute?

I know that we can use the v-model directive on an <input> element and use watch() to trigger a function when the state of the <input>'s value attribute changes. I'm trying, however, to ...
0 votes
1 answer
96 views

Parallel.ForEach and foreach returning different reference vars

(EDIT: If the title is confusing I'm all ears for a better one) I'm currently working on a small project for class in C#, and I've come into something strange. The purpose of the project is to count ...
0 votes
0 answers
26 views

#REF error only first time when copying from closed workbook. Any suggestions? (VBA)

So I am trying to copy/paste some values to reduce runtime of my macro. It is working great, but every time I open the file I want to import the values to, I get #REF in every Cell for a couple of ...
  • 1
0 votes
0 answers
31 views

how can i get ref for every grid-item while using react-grid-layout

i am trying to use react-grid-layout to draw my page. while getting each ref for grid-item, i get some trouble.. here is my code <ReactGridLayout layout={layout} {...{ ...
  • 3
-3 votes
1 answer
75 views

C# - I have a list of objects, and changing the property in one object changes the property in all of them

I'm trying to make an array of objects I created (Cat) all with random properties, but per the instructions of the assignment, I have to use a separate class (Positions) and call it with one of the ...
0 votes
0 answers
55 views

vue: why ref not found at browser but found just in console log

I fetch data then set const items = ref([]) like this items.value = resultact but why on browser doesn't it show anything show just console log? this is code <v-col cols="12"> <...
  • 1
1 vote
1 answer
103 views

How to make single property in array reactive when using `ref` instead of `reactive`?

I have a component that displays rows of data which I want to toggle to show or hide details. This is how this should look: This is done by making the mapping the data to a new array and adding a ...
0 votes
0 answers
19 views

Ininit loop occuring while I update ref in React Select when I want to check all boxes

I am working on a Select field. I am using react-select library. I have added Ref and i want to check all options, i use the setValue() on the Ref but this leads to an infinite re rendering I tried ...
0 votes
0 answers
40 views

Vue3 - ref to component child from other library

I have a problem. I want to access to original value in input in gmap autocomplete component. Im new in vue 3 and I can't do it. What wrong is here? <template> <div class="location-...
0 votes
0 answers
113 views

Does something bad happen if I keep a pointer to a ref struct in another ref struct in C#

So I want to wrap a ref struct, specifically a SequenceReader, into another ref struct. I came up with this: public ref struct PropertyAccessor { private unsafe readonly SequenceReader<byte>*...
0 votes
0 answers
36 views

How can I create a React functionnal component and get HTML attributes and ref in props with typescript?

I'm trying to make a Trello like, I'm using react-beautiful-dnd and started from the classical example. This is where I render the card (I just replaced the div with Task, my component) <Task ref=...
0 votes
1 answer
36 views

Add multiple dynamic leaflet maps with Vue3

I'm trying to add multiple leaflet maps dynamically in my Nuxt Vue 3 app. I'd like to do something like this: <div v-for="(item, index) in listitems"> <div id="map" :ref=&...
  • 139
0 votes
1 answer
36 views

React Ref is not updating the CSS

Needed to update the transform translate CSS of my imgTrack, but can't directly change it in react, was trying multiple ways to do so but, the transform property never updates(or it seems so). To do ...
0 votes
1 answer
238 views

Getting data of Material UI DataGrid

I'm working on tables with Material UI. There is data in table. I want to get its data to pass it to the next component. I tried tableRef = useRef() but failed. It returns undefined. How could it be ...
  • 160
1 vote
1 answer
46 views

How to access a DOM element in React from a custom hook?

I have a function responsable for setting a height dynamically to an element, this function is being triggered from multiple components, some of them are children of the component which has the ...
  • 1,429
0 votes
1 answer
60 views

React: Trigger onSubmit of form from parent

In my parent component I am creating a ref and passing it to child - <ChildComponent ref={submitRef}/> In my ChildComponent, I have a form whose onSubmit should be triggered when I click a ...
0 votes
0 answers
33 views

How to use update data shown in antD table using Vue 3?

I recently started using Vue 3 and am still trying to understand ref(). I created a table and a toggle button to show items with status: "active". Initially, I see the table with all the ...
  • 2,231
-1 votes
1 answer
47 views

How with formspree use preventDefault()?

I'm struggling with issue that my react form doesn't reset after clicking submit. I'm using antd form with sending mails with formspree. How I can manage my code for resetting values of my input ...
0 votes
1 answer
78 views

Vue.js Composition API vs Options API - posts ref in a v-for loop

I'm still new to VueJS, and I cannot figure this one out. I have a page that loads with axios from wordpress my posts: export default { data() { return { postsUrl: "https://localhost/...
  • 45
0 votes
0 answers
26 views

My vue3 ref const is being reset as soon as I assign a value

I'm creating an app in Laravel 9 using Vue 3. I have a list that I would like to filter, based on the selection of a dropdown. To ensure the continuity of the selection, I store the value in a ref (...
  • 313
-2 votes
2 answers
63 views

Unexpected behavior using By Ref with Reference type Dictionary

Experienced an unexpected behavior when using Dictionary type and passing by reference. Within a nested call, the reference to the underlaying base dictionary seems to be lost or replaced. All child ...
5 votes
2 answers
272 views

C# 11 escape rules for ref parameters: ref int vs Span<int>

Why does the following code not compile in C# 11? // Example 1 - fails class C { public Span<int> M(ref int arg) { Span<int> span; span = new Span<int>(ref arg); ...
  • 451
0 votes
1 answer
73 views

Table Reference In Mongodb

I have two models 1 : UserSchema & 2 :todo const userSchema = new mongoose.Schema { name: String, email: String, todo: { desc } } const todoSchema = new mongoose.Schema { id: id,...
  • 49
-1 votes
2 answers
89 views

Add Where clause to IQueryable<T> in function?

Why Where clause is not applied to IQueryable in the AddWhereToQuery function ? It should be reference type and I cannot see why this code should not work as I expect. [Route("/testing")] ...
  • 1
0 votes
1 answer
462 views

Latex equation reference not working as expected

I am preparing a report and found out \label and \eqref are not working for equations properly. \eqref giving a random equation number and not the exact equation number in the report. I have used \...
0 votes
0 answers
1k views

TypeError: Cannot read properties of undefined (reading '_ref')

I'm getting the following error when trying to filter products by category. Not exactly sure what I am doing wrong... // index.tsx const Home = ({ categories, products }: Props) => { console.log(...
0 votes
0 answers
186 views

Vite TypeScript with Qwik (SSR)

I need your help on understanding, I'm contributing to an open-source and feature that is needed is "As a user I want to click on SOMEKEY so that I can focus on the search input so I don't have ...
0 votes
1 answer
198 views

What ref does and why it's necessary in iframes?

import React from 'react' function MyComponent() { return ( <div> <p style={{color: 'red'}}>Testing to see if my component renders!</p> </div> ...
2 votes
0 answers
35 views

Adding a default value to google-places-auto-complete

I'm trying to use the city of a user as a default value to google-places-auto-complete input. I've tried to use cityAutoComplete?.setAddressText(city) outside of the ref prop but it won't work, and I'...
1 vote
1 answer
244 views

Using single ref for multiple input fields in react typescript

I am trying to use the same ref for multiple input fields in for my form. But on logging it, the ref refers only to the first input field. Is there anyway I can use the same ref and use for different ...
0 votes
1 answer
98 views

Type 'Ref<number>' cannot be used as an index type

I want to call myArray[refVariable] in Vue. How to fix following error in Vue/Typescript: Type 'Ref<number>' cannot be used as an index type
  • 159
0 votes
0 answers
67 views

console.log not display when i use ref with v-model select input vue js/quasar

currently I'm learning to use the quasar framework. there are some things that sometimes I'm still confused about seeing the results of v-model data with console.log? the case is when I use q-select ...
  • 55
0 votes
0 answers
21 views

How to pass debounceSearch to gridRef.current?.api.setQuickFilter

I have created useDebounce hook. My syntax below is not working. I was hoping somebody could tell me how to add debouncedSearch to handleSearch function. Thank you! const debouncedSearch = useDebounce(...
0 votes
1 answer
53 views

How to use ref keyword when performing mathematical operations with arrays from other methods?

I've been trying to implement a program that can take the preassigned values from a 2d array and calculate individual elements within it into 1d arrays, which are then displayed separately from the 2d ...
0 votes
0 answers
52 views

Vue 3 reactive or ref window propery / variable

How to assign window property reactivity in components of Vue 3? When use Vue via CDN I can use something like: let x = Vue.reactive({}) and in data return to use it in project data(){ return{ ...
  • 109
0 votes
0 answers
48 views

vuejs: ref tag in dom element not work when use with object attribute

With this code: <script setup lang="ts"> import { ref } from "vue" const input1 = ref(null) const group = { input2: ref(null), input3: ref(null), } function main() { ...
  • 432
0 votes
1 answer
344 views

How to use onClickOutside (vueuse) on two dom elements?

The onClickOutside function from vueuse package can be used to trigger when a click event happens outside the ref: const imageRef = ref(null) onClickOutside(imageRef, (event) => { state.active ...
0 votes
0 answers
19 views

Implementing animation when removing Toast

I have a working ToastList that enables me to click a button multiple times and generate a toast each time. On entry, I have an animation, but when I remove the toast, I do not get an animation. I am ...

1
2 3 4 5
28