I am working on an old app which used to have the following index.tsx
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { MyApp, MyAppProps } from './components';
function init(element: HTMLElement, options: MyAppProps) {
ReactDOM.render(<MyApp {...options} />, element);
}
The object MyAppProps is an interface with few defaults. Because I want to be able to change one of these defaults based on the URLParams, I thought to introduce a simple
const queryParams = new URLSearchParams(window.location.search);
const myKey = queryParams.get('myKey')
and then pass the myKey with a line like this
let MyAppProps.key = myKey
but it does not work. I cannot figure out how to correctly construct this piece of code. It seems I should create an object of the same type of the interface so that I can manipulate, but all my tests are failing.