when I go to run the command “ng n g page_name”, this error appears: “Error: This command is not available when running the Angular CLI inside a workspace“. I also tried to Right-Click on my project name in VS Code and Click “Open in Integrated Terminal”, but it doesn’t work. Can you help me? Thanks and sorry if my english is not quite correct.
Category: javascript
Category Added in a WPeMatico Campaign
why does this array throw an error when useState has default values
I’m trying to figure it out why this code throws an error when trying to get the length of the array or even when trying to render on JSX, it throws the same error.
Why does the state [postData] not use the default value before sending a get request to update it with the new data?
Pretty much, I want my initial Data to be default, until I send the request or use the setPostData(dataRequest). What am I doing wrong? Thanks
ERROR: ViewPost.js:31 Uncaught TypeError: Cannot read properties of undefined (reading ‘length’)
import React, { useEffect, useState, useContext } from 'react';
import { useParams, Link } from 'react-router-dom';
import Axios from 'axios';
import StateContext from '../StateContext';
import NotFound from './NotFound';
import iconSet from '../selection.json';
import IcomoonReact, { iconList } from 'icomoon-react';
function ViewPost() {
const { id } = useParams();
const [postData, setPostData] = useState([
{
_id: '...',
username: '...',
avatar: '...',
date: '...',
text: '...',
image: '...',
likes: [],
hearts: [],
retweet: [],
user: '...',
isFollowing: 'false',
isVerified: 'false',
comments: [{ test: 'test' }],
name: '...',
surname: '...',
},
]);
console.log(postData.comments.length) // throws an error here
const [isLoading, setIsLoading] = useState(true);
const appState = useContext(StateContext);
useEffect(() => {
async function fetchData() {
try {
const res = await Axios.get(`http://localhost:2000/api/status/${id}`);
console.log(res.data);
if (res.data) {
setPostData(res.data);
setIsLoading(false);
} else {
setIsLoading(true);
}
} catch (e) {
console.log(e.message);
}
}
fetchData();
}, [id]);
return (
<main className="main-view">
{isLoading ? (
'Loading...'
) : (
<div>
<div className="main-view__user-feed viewpost">
<div className="main-view__user-feed__author viewpost__redone">
<div className="viewpost__name">
<img
src={postData.avatar}
alt="image tweet"
className="img__viewpost"
></img>
</div>
<h2 className="viewpost__name__surname">
{postData.name} {postData.surname}
</h2>
<Link
to={`/${postData.username}`}
className="username__author__viewpost"
>
@{postData.username}
</Link>
<a href="#" className="author_post__viewpost">
{postData.text}
</a>
<div className="author__stats">
<a href="#">
<span>{postData.retweet}</span> Retweets
</a>
<a href="#">
<span>{postData.likes}</span> Likes
</a>
<a href="#">
<span>{postData.retweet}</span> Quote Tweets
</a>
</div>
<div className="icons__viewpost">
<section>
<li className="top-nav__item top-nav__item--active">
<Link to="/" className="top-nav__link">
<IcomoonReact
className="top-nav__icon"
iconSet={iconSet}
color="ffffff"
size={20}
icon="bubble2"
/>
<span>0</span>
</Link>
</li>
</section>
<section>
<li className="top-nav__item top-nav__item--active">
<a href="#" className="top-nav__link">
<IcomoonReact
className="top-nav__icon"
iconSet={iconSet}
color="ffffff"
size={20}
icon="loop2"
/>
<span>3</span>
</a>
</li>
</section>
<section>
<li className="top-nav__item top-nav__item--active">
<Link to="/" className="top-nav__link">
<IcomoonReact
className="top-nav__icon"
iconSet={iconSet}
color="ffffff"
size={20}
icon="heart"
/>
<span>2</span>
</Link>
</li>
</section>
<section>
<li className="top-nav__item top-nav__item--active">
<a href="#" className="top-nav__link">
<IcomoonReact
className="top-nav__icon"
iconSet={iconSet}
color="ffffff"
size={20}
icon="books"
/>
</a>
</li>
</section>
</div>
</div>
</div>
<div className="main-view__user-tweet viewpost__textarea">
<img src={appState.user.avatar} alt="image tweet" />
<form action="#" className="main-view__user-tweet__search">
<textarea
maxlength="250"
id="textBox1"
name="content"
TextMode="MultiLine"
className="main-view__user-tweet__input"
onkeyup="setHeight('textBox1');"
onkeydown="setHeight('textBox1');"
placeholder="Tweet your reply"
></textarea>
</form>
<a href="#" className="main-view__user-tweet__button">
Reply
</a>
</div>
</div>
)}
{isLoading
? 'Loading...'
: postData.comments.map((comment) => {
return (
<div className="main-view__user-feed">
<img src={comment.avatar} alt="image tweet"></img>
<div className="main-view__user-feed__author">
<div className="name">
<h2>
{comment.name} {comment.surname}
</h2>
<Link
to={`/${comment.username}`}
className="username__author"
>
@{comment.username}
</Link>
</div>
<p className="reply-p">
Replying to <a href="">@{postData.username}</a>
</p>
<a href="#" className="author_post">
{comment.text}
</a>
<div className="icons">
<section>
<li className="top-nav__item top-nav__item--active">
<a href="#" className="top-nav__link">
<svg className="top-nav__icon">
<use xlinkHref="img/sprite.svg#icon-bubble2"></use>
</svg>
<span>0</span>
</a>
</li>
</section>
<section>
<li className="top-nav__item top-nav__item--active">
<a href="#" className="top-nav__link">
<svg className="top-nav__icon">
<use xlinkHref="img/sprite.svg#icon-loop2"></use>
</svg>
<span>0</span>
</a>
</li>
</section>
<section>
<li className="top-nav__item top-nav__item--active">
<a href="#" className="top-nav__link">
<svg className="top-nav__icon">
<use xlinkHref="img/sprite.svg#icon-heart"></use>
</svg>
<span>0</span>
</a>
</li>
</section>
<section>
<li className="top-nav__item top-nav__item--active">
<a href="#" className="top-nav__link">
<svg className="top-nav__icon">
<use xlinkHref="img/sprite.svg#icon-books"></use>
</svg>
</a>
</li>
</section>
</div>
</div>
</div>
);
})}
</main>
);
}
export default ViewPost;
JavaScript: How to dynamically get the name of the method inside the method in a class?
I would like to get the name of the method inside the method in a class and throw an error when one argument is passed to the method. For example, if the name of the instance is instance_of_cookie and the name of the method is (for simplicity) the_method, then passing one argument to that method should throw an error like "instance_of_cookie.the_method" expected two arguments or simply "the_method" expected two arguments.
I can get the name of the function inside the function using arguments.calle.name. But that doesn’t seem to work inside class methods and throws the following error:
VM10:4 Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
at Cookie.the_method (<anonymous>:4:28)
at eval (eval at the_method (:4:28), <anonymous>:1:32)
at Cookie.the_method (<anonymous>:4:28)
at <anonymous>:13:32
I came across a post which mentioned this.constructor.name but that gives me the name of the class.
class Cookie {
the_method(x, y) {
if (y == undefined) {
return `'${this.constructor.name}' expects two arguments; one was given`;
} else {
return "Everything's OK"
}
}
}
let instance_of_cookie = new Cookie();
console.log(instance_of_cookie.the_method(8))
Is there any way I can get the name of the method inside the method in a class?
(Note: I can hard-code the name of the method, but for some reasons, I don’t want to do that.)
Can I send a stream of images from a raspberry pi to android using chrome web bluetooth low energy API?
Currently I have a HTML/Javascript web application working on my Android that can pair with a raspberry pi using the Chrome web bluetooth api. I understand that up to 512 bytes can be sent through a GATT characteristic which is too small for my purposes. Is there a way to send a stream of images (or even just one image for now) from the pi to my android over BLE with this web bluetooth api?
Here is the javascript code to request the raspberry pi below. I have python scripts running on the pi to advertise itself and its services/characteristics. Currently I have a custom GATT characteristic that I have built but can’t send an image through because of the 512 byte limit. After using the API to find/connect to the pi, is there another way to send images from the pi back to the android?
//device and characteristic variables
var bluetoothDevice;
var imageCharacteristic;
//decoder for array buffer -> string
var enc = new TextDecoder("utf-8");
//UUIDs
//service uuid
const serviceUUID = '00000001-710e-4a5b-8d75-3e5b444bc3cf'
//write characteristic for taking an image on the pi
const imageCharacteristicUUID = '00000007-710e-4a5b-8d75-3e5b444bc3cf'
//button 1: change connect/disconnect button when clicked
connectButton.addEventListener('click', function handleClick() {
const initialText = 'Connect';
if (connectButton.innerText.includes(initialText)) { //user clicks 'connect'
//check if see if bluetooth device has already been requested
return (bluetoothDevice ? Promise.resolve() : requestDevice())
.then(connectDevice)
.then(_ => {
connectButton.innerText = 'Disconnect';
document.getElementById("status").innerHTML = 'BT Connected';
})
.catch(error => {
console.log('error' + error);
});
} else { //user clicks 'disconnect'
if (bluetoothDevice.gatt.connected) { //error handling to ensure device is actually connected
console.log('disconnecting...')
bluetoothDevice.gatt.disconnect();
} else {
console.log('Bluetooth Device is already disconnected');
}
}
})
//request device using web bluetooth api
function requestDevice() {
return navigator.bluetooth.requestDevice({
//filter to search for one device
filters: [
{name: 'rasPi'},
{services: [serviceUUID]}
]
})
.then(device => {
bluetoothDevice = device;
})
}
//connect to device and register services and characteristics
function connectDevice() {
if (bluetoothDevice.gatt.connected) {
return Promise.resolve();
}
console.log("connected");
return bluetoothDevice.gatt.connect()
.then(server => server.getPrimaryService(serviceUUID))
.then(service => service.getCharacteristics())
.then(characteristics => {
//start a queue to gather each characteristic
let queue = Promise.resolve();
characteristics.forEach(characteristic => {
switch (characteristic.uuid) {
case BluetoothUUID.getCharacteristic(imageCharacteristicUUID) :
queue = queue.then(_ => {
imageCharacteristic = characteristic;
})
break;
default : console.log('Unknown Characteristic: ' + characteristic.uuid);
}
});
return queue;
})
}
flotcharts – yaxis tick names not aligned to bars
I’m using this code to get my chart working
var d1 = [
[0, 3],
[1, 8],
[2, 5]
];
var d2 = [
[0, 3],
[1, 8],
[2, 5]
];
var d3 = [
[0, 3],
[1, 8],
[2, 5]
];
var d4 = [
[0, 3],
[1, 8],
[2, 5]
];
function plotWithOptions() {
$.plot("#placeholder", [
{ label: "novo", data: d1 },
{ label: "revisao", data: d2 },
{ label: "bla1", data: d3 },
{ label: "bla2", data: d4 },
], {
series: {
stack: 0,
bars: {
show:true,
horizontal:true,
}
},
yaxis: {
tickLength: 1,
gridLines: false,
ticks: [
[0, 'Bob'],
[1, 'Chris'],
[2, 'Joe'],
]
}
});
}
$(document).ready(function(){
plotWithOptions();
});
The problem is that the tick names are not aligned to bars.
Am I doing something wrong?
My condition is partially respected and I don”t understand why with REACT
Hello I tried to put this condition in my data but only this part is working :
showGood ? matchData : matchData.filter((i) => i.state !== "Good") so when I try to filter my data via my dropdowns it’s not working except if I do :
data={filtersMenu} but then my condition where state==="Good" is not respected.
At the begining I had :
data={matchData && showGood ? matchData : matchData.filter((i) => i.state !== "Good")}.
So I tried also data={showGood ? matchData && filtersMenus : matchData.filter((i) => i.state !== "Good")}; but not working either (I mean working partially since one condition is respected)…
export default function MenuDisplay() {
const { menuId } = useParams();
const [menus, setMenus] = useState([]);
const [selected, setSelected] = useState({});
const [hidden, setHidden] = useState({});
const [taste, setTaste] = useState([
{ label: "Good", value: "Good", name: "Good", selected: false },
{ label: "Medium", value: "Medium", name: "Medium", selected: false },
{ label: "Bad", value: "Bad", name: "Bad", selected: false }
]);
...
useEffect(() => {
myapi.menusFunction(parseInt(menuId))
.then(res => {
const menus = res.data.menus;
setMenus([
...menus.filter((i) => i.state === "Good"),
...menus.filter((i) => i.state !== "Good")
])
})
.catch(err => {
console.log(err)
})
}, [menuId]);
// If any row is selected, the button should be in the Apply state
// else it should be in the Cancel state
const buttonMode = Object.values(selected).some((isSelected) => isSelected)
? "apply"
: "cancel";
const rowSelectHandler = (id) => (checked) => {
setSelected((selected) => ({
...selected,
[id]: checked
}));
};
const handleClick = () => {
if (buttonMode === "apply") {
// Hide currently selected items
const currentlySelected = {};
Object.entries(selected).forEach(([id, isSelected]) => {
if (isSelected) {
currentlySelected[id] = isSelected;
}
});
setHidden({ ...hidden, ...currentlySelected });
// Clear all selection
const newSelected = {};
Object.keys(selected).forEach((id) => {
newSelected[id] = false;
});
setSelected(newSelected);
} else {
// Select all currently hidden items
const currentlyHidden = {};
Object.entries(hidden).forEach(([id, isHidden]) => {
if (isHidden) {
currentlyHidden[id] = isHidden;
}
});
setSelected({ ...selected, ...currentlyHidden });
// Clear all hidden items
const newHidden = {};
Object.keys(hidden).forEach((id) => {
newHidden[id] = false;
});
setHidden(newHidden);
}
};
const matchData = (
match.filter(({ _id }) => {
return !hidden[_id];
});
const data = [
...
{
Header: "Show",
accessor: (row) => (
<Toggle
value={selected[row._id]}
onChange={rowSelectHandler(row._id)}
/>
)
}
];
const reset = (list) =>
list.map((v) => ({
...v,
selected: false
}));
const cancel = () => {
setTaste(reset(taste))
...
};
const filtersMenu = matchData.filter((menu) => {
const allTaste = taste.every(i => i.selected === false)
const selTaste = (taste.filter((e) => e.selected)).map(({ value }) => value);
const allTasteSel = selTaste.indexOf(menu.taste) >= 0
...
return allTasteSel && ...
});
return (
<div>
<Toggle value={!showGood} onChange={() => setShowGood(!showGood)} />
<button onClick={handleClick}>
{buttonMode === "reset" ? "reset" : "Hide"}
</button>
<Table
data={filtersMenu && showGood ? matchData : matchData.filter((i) => i.state !== "Good")}
columns={data}
/>
</div>
);
}
Convert Javascript String to Map Flutter
I have a string like this:
‘var key1 = “abcd”;
var key2 =”xyz”;’
and I want to convert this into the map or json in dart like this:
{
‘key1’: ‘abcd’,
‘key2’: ‘xyz’
}
is there a way I can convert JS file as string to dart map?
Stop rendering UseEffect of Click of a specific function
In my Application when ever i change the number i want run the UseEffect Hook and re-render the updated values in the array which is working, but one condition i don’t want to run the use UseEffect Hook is when i click addRow function i want bank field should be added in the rows except the number
JsCode
const [number, setNumber] = useState(3);
const [data, setData] = useState([]);
const [insValue,setInstValue]=useState(90);
useEffect(() => {
const list = [];
for (let i = 1; i <= number; i++) {
let ins = instValue/number;
list.push({
insNo: i,
installmentAmount: ins,
chequeNumber: '',
});
}
setData(list);
}, [number]);
const addRow = () => {
setNumber((number) => number + 1);
console.log('Add item clicked');
data.push({
insNo: number + 1,
installmentAmount: '',
chequeNumber: ''
});
const list = [...data];
setData(list);
};
Html
<div onClick={addRow}>
ADD ROW
</div>
currently what it is happening is when i click on add row number get changed and useffect Runs and data get updated i need is blank field in the row on the last object of an array
Output Getting
[{"insNo":1,"installmentAmount":22.5,"chequeNumber":""},
{"insNo":2,"installmentAmount":22.5,"chequeNumber":""}
{"insNo":3,"installmentAmount":22.5,"chequeNumber":""}
{"insNo":4,"installmentAmount":22.5,"chequeNumber":""}]
Output i need on click of addRow
[{"insNo":1,"installmentAmount":30,"chequeNumber":""},
{"insNo":2,"installmentAmount":30,"chequeNumber":""}
{"insNo":3,"installmentAmount":30,"chequeNumber":""}
{"insNo":4,"installmentAmount":"","chequeNumber":""}]
Set the value of an input via dev tools such that Angular recognizes it?
I’m trying to streamline a bit of work within GA4 where I have a set of dimensions to create for a long list of GA4 properties. Navigating to the Custom definitions screen, I have a script I run in the dev tools console that is set up to simply click/type what I would typically do by hand.
However, after executing the code, the page doesn’t recognize that the field was changed, and some kind of validation doesn’t execute, so the save button remains disabled. Further, if I then click into the field, form field validation shows an error, but copy and pasting the same text resolves the issue.
Here’s the relevant portion of the code I’m running:
document.querySelector('button.create-definition-button').click();
document.querySelector('definition-builder input.custom-name-control').value = dimensions[i].customName;
I’ve attempted to further emulate what I do by hand by trying any mix of the following types of things:
document.querySelector('definition-builder input.custom-name-control').click();
document.querySelector('definition-builder input.custom-name-control').blur();
document.querySelector('definition-builder input.custom-name-control').dispatchEvent(new Event('change'));
Unfortunately with no luck. Ideas?
country-state-city does not load at all
I’m continuously having a problem with country-state-city in my react app. Code to pull it is as follows and the error is right below it. I haven’t the slightest clue and I’ve been searching everywhere.
import { useState, useEffect } from 'react';
import { Box, TextField, Button, InputAdornment } from '@mui/material';
import csc from 'country-state-city';
export const Markups = () => {
const [country, setCountry] = useState({});
useEffect(() => {
const getStates = async() => {
try {
let country_abbrv = 'US';
let country = await csc.getCountryByCode(country_abbrv);
let temp_states = await csc.getStatesOfCountry(country.isoCode);
console.log(temp_states);
} catch (err) {
console.log(err);
}
};
getStates();
})
TypeError: Cannot read properties of undefined (reading 'getCountryByCode')
at getStates (index.js:13:1)
at index.js:22:1
at commitHookEffectListMount (react-dom.development.js:23142:1)
at commitPassiveMountOnFiber (react-dom.development.js:24920:1)
at commitPassiveMountEffects_complete (react-dom.development.js:24885:1)
at commitPassiveMountEffects_begin (react-dom.development.js:24872:1)
at commitPassiveMountEffects (react-dom.development.js:24860:1)
at flushPassiveEffectsImpl (react-dom.development.js:27032:1)
at flushPassiveEffects (react-dom.development.js:26978:1)
at commitRootImpl (react-dom.development.js:26929:1)
Open Mapping Application Depending on Device
I am developing an app using QML. I am trying to enable directions for a feature in the app by opening the device’s mapping app.
For most Androids, this means opening up Google Maps. For iOS device’s this could mean either opening Apple Maps OR Google Maps depending on which app the user has downloaded on their phone.
Is there code that will switch to Google Maps if Apple Maps is not installed on a users phone?
Here is my code that I have currently
MouseArea {
anchors.fill: parent
preventStealing: true
onClicked: {
if(app.enableDistance && app.showDistance && app.isOnline) {
var link = "http://maps.google.com?daddr="+address+"&saddr="+app.locationManager.latitude+","+app.locationManager.longitude+"&zoom=14&views=traffic&&directionsmode=driving&x-success=sourceapp://?resume=true"
if(Qt.platform.os == "ios") {
link = "http://maps.apple.com/?daddr=" + address + "&dirflg=d"
}
if(Qt.platform.os == "ios" || Qt.platform.os == "android") {
Qt.openUrlExternally(link)
}
}
}
}
These links work successfully as long as the user has either Google Maps installed on their Android device or Apple Maps installed on their iOS device. If a iOS user doesn’t have Apple Maps, it prompts the user to download Apple Maps in the store.
Any tips would be helpful. Thanks!
React set text content but not html
I’m wondering if there is a React equivalent of setting node.textContent to defend against scripting attacks. Currently I am just doing
<p>{name}</p>
But of course this isn’t text content and could be prone to attacks. I want to avoid having to do sanitization if a direct textcontent is possible.
JS nested object keys to array
{
"CLASSIQUES": {
"ANGULES": {
"INDEXES": {},
"NON INDEXES":{}
},
"DROITS": {
"INDEXES": {},
"NON INDEXES": {}
}
},
"ETROITS": {
"ANGULES": {},
"DROITS": {}
}
}
Hi everyone,
I’m making an ecommerce website. For each group of products, I’ve an object of objects like this. It refers to different levels and sublevels of a product catalogue and I’d like to display those keys in list in react keeping the hierarchical order of the object. I’ve tried a forEach method on the Object.entries to get an array but I can’t seem to figure it out. Here’s an example of what I’d like to display :
- CLASSIQUES
- ANGULES
- INDEXES
- NON INDEXES
- DROITS
- INDEXES
- NON INDEXES
- ANGULES
- ETROITS
- ANGULES
- DROITS
Thanks for any help
Close Nav Menu On Click After Selecting Page
I am trying to get my Javascript to close my nav menu bar after I choose a page from the dropdown menu. Currently, if I toggle the hamburger icon, it will show the menu, but when I click on one of the links in the menu bar, it takes my to that section, and the dropdown menu bar stays on screen. I would like for it to disappear after I tap one of the links in the menu bar.
HTML
<nav>
<div class="logo">
<a href="index.html"><p class="logo-p"><i class = "fa-solid fa-code"></i><strong> HIBBERT</strong> DEVELOPMENT</p></a>
</div>
<div class="hamburger">
<div class="line1" style="width: 1.5rem;"></div>
<div class="line2" style="width: 1rem;"></div>
<div class="line3" style="width: 0.5rem;"></div>
</div>
<ul class="nav-links">
<li><a href="index.html">HOME</a></li>
<li><a href="#offer">OFFER</a></li>
<li><a href="#services">SERVICES</a></li>
<li><a href="#about">ABOUT</a></li>
<li><a href="#contact">CONTACT</a></li>
<li><a href="https://dylanhibbert.info">PORTFOLIO</a></li>
</ul>
</nav>
<script src="index.js"></script>
JavaScript
const hamburger = document.querySelector(".hamburger");
const navLinks = document.querySelector(".nav-links");
const links = document.querySelectorAll(".nav-links li");
hamburger.addEventListener('click', ()=>{
//Animate Links
navLinks.classList.toggle("close");
navLinks.classList.toggle("open");
navLinks
links.forEach(link => {
link.classList.toggle("fade");
});
//Hamburger Animation
hamburger.classList.toggle("toggle");
});
Problem while passing useState variable from one JSX file to another
(Column.jsx)
import React, { useState, useEffect } from "react";
import Axios from "axios";
import "./styles.css";
function CreateColumn() {
let [val1, setVal1] = useState("0");
let [val2, setVal2] = useState("0");
let [secName, setSecName] = useState("");
let [goAttendance, setGoAttendance] = useState(0);
function valueChanged(event) {
const checkChecked = event.target.id;
// console.log(checkChecked);
if (checkChecked === "section1") {
setVal1("1");
setVal2("0");
setSecName("Section 1");
} else if (checkChecked === "section2") {
setVal2("1");
setVal1("0");
setSecName("Section 2");
} else {
setVal1("0");
setVal2("0");
setSecName("");
}
}
useEffect(() => {
Axios.get("http://localhost:9000/createColumn").then((response) => {
setSecName(response.data);
});
}, []);
function sendColumn(event) {
setGoAttendance(1);
Axios.post("http://localhost:9000/createColumn", { secName, goAttendance });
}
return (
<div>
<form className="form-body">
<div className="form-check check-line center-col">
<input
className="form-check-input"
type="checkbox"
id="section1"
name="section"
value={val1}
checked={val1 === "1"}
onChange={valueChanged}
/>
</div>
<div className="form-check check-line center-col">
<input
className="form-check-input"
type="checkbox"
id="section2"
name="section"
value={val2}
checked={val2 === "1"}
onChange={valueChanged}
/>
</div>
<div className="submit-btn d-grid gap-2 d-md-flex justify-content-md-center">
<button
type="submit"
className="btn btn-lg btn-primary"
onClick={sendColumn}
>
Create
</button>
</div>
</form>
</div>
);
}
export default CreateColumn;
(Attendance.jsx)
import React, { useState, useEffect } from "react";
import Axios from "axios";
import TableTitle from "./TableTitle";
import Pagination from "./Pagination";
import "./styles.css";
function Attendance() {
const [attedanceList, setAttedanceList] = useState([]);
useEffect(() => {
Axios.get("http://localhost:9000/attendance/" + **WANT TO USE secName FROM Column.jsx HERE**).then(
(response) => {
setAttedanceList(response.data.data.values);
}
);
}, []);
function sendAllValues(event) {
Axios.post("http://localhost:9000/attendance", { attedanceList });
}
return (
<form className="form-body">
<TableTitle />
<Pagination data={attedanceList} />
<div className="submit-btn d-grid gap-2 d-md-flex justify-content-md-center">
<button
type="submit"
className="btn btn-lg btn-primary"
onClick={sendAllValues}
>
Submit
</button>
</div>
</form>
);
}
export default Attendance;
(App.jsx)
import React, { useState } from "react";
import Attendance from "./Attendance";
import CreateColumn from "./CreateColumn";
function App() {
return (
<div>
<CreateColumn />
**WANT TO USE goAttendance FROM Column.jsx HERE** && <Attendance />
</div>
);
}
export default App;
I wanna see useState variables (secName and goAttendance) from Column.jsx in Attendance.jsx and App.jsx (where I have marked as WANT TO USE…). How is it possible? I tried so many things for hours but sometimes it breaks my code or simply have to change a lot which makes the code more messy and buggy.

