i can get this axios info with class component , but i can't convert it into simple function ,i should say that in my code i use redux,in fact this code should call from another component,and pull some info from there no matter what kind of info i get from axios, i just need to get that info from there and put it in my code
class PostList extends Component {
constructor(props) {
super(props);
this.state = {
info: []
};
}
componentDidMount() {
axios
.get("https://api2.binance.com/api/v3/ticker/24hr")
.then((response) => {
this.setState({
info: response.data
});
console.log(response.data);
});
}
render() {
const { info } = this.state;
return (
<div>
<h2>post!</h2>
{info.map((user) => (
<div key={user.symbol}>
<h6>{user.priceChange}</h6>
</div>
))}
</div>
);
}
}
export default PostList;```
i want convert it like this ,because i use redux and i need to give it in other component
```export const PostList = () =>{
return (
//my code using axios,
)
}```
here is my link
[https://codesandbox.io/s/intelligent-meninsky-dmvdw?file=/src/App.js]
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment