What is the process for updating a property in Inertia.js and Vue.js?

I am attempting to modify the list property in Vue.js using Inertia.js:

props: {
    list: {
        type: Object, 
        default: {}
    }
},
updateTable(filters) {
    axios.post(route('updateList'), filters)
        .then(r => {
            this.list = r.data
        })
}

However, I encountered the error message:

TypeError: 'set' on proxy: trap returned falsish for property

In Inertia.js, all props are provided as proxies. According to this MDN article, the proxy's set method must return true for allowing assignment. I'm unsure how to achieve this correctly since I didn't create the proxy myself. Any suggestions?

Do I always need to resort to a partial reload when working with Inertia?

Answer №1

There seems to be some confusion regarding the workings of Vue and Inertia in this scenario.

The prop list is being passed to you, and it's generally discouraged to directly modify props.

If necessary, you can access it using this.$page.props.list rather than receiving it as a prop.

Alternatively, you could consider implementing the following approach:

export default {
   props: {
      list: {
         type: Object,
         default: {}
      }
   },
   data () {
      return {
         listCopy: this.list
      }
   },
   mounted () {
      // Implement your scroll events here
      axios.get(this.listCopy.next_page_url).then(response => {
         this.listCopy = {
            ...response.data,
            data: [...this.listCopy.data, ...response.data.data]
         }
      })
   }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the method for selecting an element using CSS code in Protractor?

Having trouble clicking on the element with CSS Selector: <button _ngcontent-c16="" class="btn btn-flat btn-no-text btn-kebab-view"> <i _ngcontent-c16="" class="zmdi zmdi-more-vert"></i> </button> This is what I've t ...

Strategies for extracting methods and refactoring to a separate file for better reusability

Still relatively new to the JQuery/javascript realm, I've put together a functional jqgrid with a datepicker and custom control (using jquery auto complete) by piecing together code samples I came across online. This code has been added to a T4 templa ...

What are the steps to utilize V-mask for showing numbers in the thousands with a decimal point?

Hello, I have an input field where I am trying to apply a mask in order to display numbers like 1.000 or 1.000.000 with thousands separated by dots. However, the current code I have is not working as expected. Here is what I currently have: <input type= ...

Adding custom styles to an unidentified child element in React using Material-UI

When the function below is executed in a loop, I need to include styles for the icon which will be passed as an argument to the function. The icon element will be an unspecified React Material-UI Icon component. const renderStyledCard = (lightMode, headi ...

Feeling unsure about the concepts of scoping and the "this"

Recently, I came across a code snippet at this source: : var CounterButton = function(el){ this.$el = $(el); this.counter = 0; this.bindEvents(); this.myVal = 1; } CounterButton.prototype.bindEvents = function(){ this.$el.click(this. ...

Vuex was unable to locate the required dependency

Currently, I'm following an instructional video that incorporates Vuex. As shown in my package.json dependencies, I have installed Vuex: { "name": "blabla", "version": "1.0.0", "description": "blablaa", "author": "blabla", "private": true, ...

We have encountered an issue with the syntax in the code: ajaxsample/update_agenda. It seems to be an unrecognized expression according to

Here's the code for updating my controller: public function update_agenda() { $id= $this->input->post('did'); $this->load->model('agenda_model'); $data = array ( ...

Fetching server-side data for isomorphic React app: A guide to accessing cookies

Currently, I am in the process of developing an isomorphic/universal React + Redux + Express application. The method I use for server-side data fetching is quite standard: I identify the routes that match the URL, call the appropriate data-fetching functio ...

Tips for creating a script that compiles all SCSS files into CSS within a Vue 3 project

Within my project, there exists a file named index.scss located in the src/assets/styles directory. Adjacent to this file are multiple folders housing SCSS files that are ultimately imported into index.scss. My objective is to devise a script within the pa ...

Using Vue.js to utilize a component within another component

I have a component that I would like to utilize within another component in order to create a navigation menu. I am looking to separate the menu from the links. How can I display data in a child component within another parent component while using Vue.js ...

I am attempting to establish a connection with the Converge Pro 2 system from Clearone using NodeJS node-telnet-client, but unfortunately, my efforts to connect have been unsuccessful

My connection settings are as follows: { host: '192.168.10.28', port: 23, shellPrompt: '=>', timeout: 1500, loginPrompt: '/Username[: ]*$/i', passwordPrompt: '/Password: /i', username: 'clearone ...

Is there a way to disable responsiveness on a website?

Currently, I am in the process of developing a responsive style sheet that is live on our website. However, it seems to display poorly on non-desktop devices due to being a work in progress. I am considering using JavaScript to enforce the desktop layout ...

The most lightweight scraper for individual website pages

There is a certain website that constantly updates its data. Unfortunately, there is no API available to access this information programmatically in JavaScript, which presents a common challenge for me. To tackle this issue, I have created a simple JavaSc ...

Exploring Next.js: Leveraging fetch to retrieve data in getServerSideProps and passing it to the client via query parameters

I'm utilizing a getServerSideProps function on the directory page. pages/catalog/index.js export async function getServerSideProps(ctx) { const response = await fetch( `http://someDomen.com/api/ipro/catalog?${ctx?.query?.page ? `page=${ctx.quer ...

What is the best method for enabling communication between two users when the identification numbers created by socketIO are automatically generated?

Hey there, hope you're doing well. I've been pondering a question that has left me stumped. I recently came across a course that explained how to send a message to a specific user using socketIO.js by utilizing the `to()` method and passing the ...

Streamlining a map-generated object

Looking to streamline this code, specifically the declaration of the variable codes. Is there a way to simplify this? const numbers = [ { id1: 1, id2: 2, id3: 3, pos: "a" }, { id1: 4, id2: 5, id3: 6, pos: "b" }, { id1: 7, id2: 8, ...

Identifying the specific filter used in Vue-tables-2

Trying to configure a basic server-side vue-tables-2 with dual filters - one dropdown and the other a search field. The challenge here is identifying which filter was applied within the requestFunction() in order to send a server request. My current strate ...

Switching from Vanilla JS to Vue.js, dealing with querySelector problems

Seeking assistance with transforming the following CodePen example to a Vue.js component: https://codepen.io/kjbrum/pen/qooQJJ While attempting to incorporate this.$nextTick for handling DOM manipulation, I'm encountering challenges in making it func ...

Integrating Asp.Net Core for server-side functionality with React for client-side interactions

I have started a simple Asp.Net default project in Visual Studio 2015 using the template: ASP.NET Core Web Application (.NET Core) / Web Application, No Authentication. Following that, I created a package.json file to load all the necessary packages for R ...

When should you opt for a plugin over a traditional module in Fastify?

I am uncertain about the best practices for using plugins in Fastify.js. For instance, if I have a lib/utils.js file containing utility functions, my usual approach would be to simply require() them wherever necessary in my app. What advantages are there ...