How can I extract the useState from the file. It is necessary to export exactly sliderCount for further work. Thanks in advance.
There are 2 files. The first file uses the useState function and changes the state when the button is clicked. In the second file, I want to get the changed state of useState from the first file and continue to work with it.
Make conditions, etc., for example:
if(sliderCount == 1){
console.log('Number 1')
}
if(sliderCount == 2){
console.log('Number 2')
}
First file:
import React, {useState} from "react";
function ContainerAtwSwap() {
const [sliderCount, setSliderCount] = useState(0)
return (
<div className="container_button__swap-main">
<div className="dropdown">
<div className="dropdown-content">
<button className="button__swap-button" onClick={() => setSliderCount(1)}>№1</button>
<button className="button__swap-button" onClick={() => setSliderCount(2)}> №2</button>
<button className="button__swap-button" onClick={() => setSliderCount(3)}>№3</button>
</div>
</div>
</div>
)
}
export default ContainerAtwSwap
Second file:
import React from 'react';
function WorkingEnvironment() {
..here I wanted to make conditions, etc.
return (
<div className='boxControl scroll' id='boxSliderOne'>
<div className='container-slider'>
{}
</div>
</div>
);
}
export default WorkingEnvironment;