Check out example codes for "javascript use css custom properties". It will help you in understanding the concepts better.

Code Example 1

Values in JavaScript
To use the values of custom properties in JavaScript, it is just like standard properties.
// get variable from inline style"--my-var");

// get variable from wherever

// set variable on inline style"--my-var", jsVar + 4);

Learn ReactJs, React Native from