无法访问功能中的道具

时间:2020-11-10 11:36:52

标签: reactjs react-hooks

const OrderComplete = ({
stage
}) =>

const someFunction = () => { console.log(stage) }

useEffect(()=> setTimeout(()=>someFunction(),1000),[])
...

我正在获得阶段不确定的价值。但是,如果我使用react dev工具并查看像这样的组件道具

组件中的值

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

您应该使用from tkinter import * from moviepy.editor import * window = Tk() e = Entry(window, width=50) e.pack() def myClick(): myLabel = Label(window, text="Converting the file named : " + e.get()) myLabel.pack() myButton = Button(window, text="Convert", command=myClick) video = e.get() myButton.pack() mp4_file = video mp3_file = "{}.mp3".format(mp4_file) videoClip = VideoFileClip(mp4_file) audioclip = videoClip.audio audioclip.write_audiofile(mp3_file) audioclip.close() videoClip.close() window.mainloop() 的依赖项数组:

useEffect

因为如果传递一个空数组,则回调将仅在const OrderComplete = ({ stage }) => const someFunction = () => { console.log(stage) } useEffect(()=> setTimeout(()=>someFunction(),1000),[someFunction]) 道具可能为stage的情况下才在初始渲染时生效