Skip to content

Commit

Permalink
fixed issue where the post_put callback for WithEndpoint would be cal…
Browse files Browse the repository at this point in the history
…led twice
  • Loading branch information
ANeaves committed Nov 28, 2023
1 parent 93b43b5 commit da1bc22
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 8 additions & 1 deletion example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ import EndpointExamplePage from './EndpointExample';
import WorkshopExamplePage from './WorkshopExample';
import GraphExamplePage from './GraphExample';



const App = () => {


const postPutMethod = () => {
console.log("Post Message Method Called");
}

return (
<OdinApp title="Odin React Example"
navLinks={["Workshop", "With Endpoint Examples", "Graph Examples"]}>
<WorkshopExamplePage />
<EndpointExamplePage />
<EndpointExamplePage postPutMethod={postPutMethod}/>
<GraphExamplePage/>

</OdinApp>
Expand Down
5 changes: 1 addition & 4 deletions example/src/EndpointExample.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const EndpointDoubleSlider = WithEndpoint(OdinDoubleSlider);


function EndpointExamplePage(props) {
const {postPutMethod} = props;

const staticEndpoint = useAdapterEndpoint("react", process.env.REACT_APP_ENDPOINT_URL);
const periodicEndpoint = useAdapterEndpoint("react", process.env.REACT_APP_ENDPOINT_URL, 1000);
Expand All @@ -41,10 +42,6 @@ function EndpointExamplePage(props) {
console.log("Pre Message: %s", message);
}

const postPutMethod = () => {
console.log("Post Message Method Called");
}

return (
<Container>
<Row>
Expand Down
1 change: 0 additions & 1 deletion src/services/withEndpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ function WithEndpoint(WrappedComponent)
post_method();
}
}
post_method && post_method(...post_func_kwargs.current);
})
.catch((err) => {
setError(err);
Expand Down

0 comments on commit da1bc22

Please sign in to comment.