在构造函数中设置状态时流程给出错误

时间:2018-11-02 22:29:42

标签: javascript reactjs react-native flowtype

我正在尝试将Flow in与我的react代码一起使用,但无法解决此1错误。 这是我的代码

def count_me_other_2(words,text):
    wordlist = words.split()
    splitted = (x.strip(".,!?") for x in text.split())
    d = {}
    for w in splitted:
        if w not in d:
            d[w]=1
        else:
            d[w]+=1
    for w in wordlist:
        print(f"The word {w} appears {d.get(w,0)} times.")

def count_me_other_3(words,text):
    from collections import defaultdict            
    wordlist = words.split()
    splitted = (x.strip(".,!?") for x in text.split())
    d = defaultdict(int)
    for w in splitted:
        d[w] += 1
    for w in wordlist:
        print(f"The word {w} appears {d.get(w,0)} times.")


count_me_other_2(wordlist,text)
count_me_other_3(wordlist,text)

以上两行引发错误type State = { showClearSearchButton: Boolean, location: String }; class XYZ extends Component<State> { constructor (props: any) { super(props); this.state = { showClearSearchButton: false, (this line throws error) location: '' (this line throws error) }; } }

我无法找到解决方案,也尝试过this方法,但是不起作用。请任何人可以帮助吗?

0 个答案:

没有答案