-
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
Description
To make my code cleaner I'm exporting my Component into their separate file.
By doing so I'm having an issue as I can't access useSharedCounter
Should I try to pass
Rather than
const useSharedCounter = () => useBetween(useCounter);
const Count = () => {
const { count } = useSharedCounter();
return <p>{count}</p>;
};
const Buttons = () => {
const { inc, dec } = useSharedCounter();
return (
<>
<button onClick={inc}>+</button>
<button onClick={dec}>-</button>
</>
);
};
const App = () => (
<>
<Count />
<Buttons />
<Count />
<Buttons />
</>
);
export default App;
I am trying to do the following
But I can't see to retrieve the useSharedCounter={useSharedCounter} function in either Button.js or Count.js
Is this possibel to perform such refactoring with this library?
import Button from "./Button.js'
import Count from "./Count.js'
const useSharedCounter = () => useBetween(useCounter);
const App = () => (
<>
<Count useSharedCounter={useSharedCounter} />
<Buttons useSharedCounter={useSharedCounter} />
<Count useSharedCounter={useSharedCounter} />
<Buttons useSharedCounter={useSharedCounter} />
</>
);
export default App;
Reactions are currently unavailable