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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/LvB3QAAAMFJREFUeNpiqIcAbz0ogwFKm7GgCjgyZMihCLCkc0nk
IAnIMVRw2UhDBGp5fcurGOyLfbhVtJwLdJkY8oscZCsFPBk5spiNaoTC4hnqk801Qi2zLQyD2NlcWWP5GepN5TOtSx
g1QwrV01itpECG2kaLy3AYiCWxcRozQWyp9pNMDWePDI4QgVpbx5eo7a+mHFOqAxUQVeRhdrLjdFFQggqo5tqVeSS4
56UEQgWE4/RBboxyC4AKCEI9Wu9lUl8PEGAAV7NY4hyx8voAAAAASUVORK5CYII=';

Image 컴포넌트

<Image 
style={{width: 100, height: 50, resizeMode: Image.resizeMode.contain, borderWidth: 1, borderColor: 'red'}}
source={{uri: base64Icon}}/>

 

style로 width와 height를 반드시 설정해줘야 출력이 된다.

 

 

npm install base-64

.d.ts 를 지원하므로 typescript로 작성한다면 @types/basic-64를 설치하면 됨.

 

import base64 from 'base-64';

let username = 'user';
let password = 'passwd';

let headers = new Headers();

//headers.append('Content-Type', 'text/json');
headers.append('Authorization', 'Basic' + base64.encode(username + ":" + password));

fetch(url, {method:'GET',
        headers: headers,
        //credentials: 'user:passwd'
       })
.then(response => response.json())
.then(json => console.log(json));
//.done();

function parseJSON(response) {
return response.json()
}

나의 경우 아래와 같이 작성함

        let data = {
            method: 'POST',
            // body: JSON.stringify({

            // })
            headers: {
                Accept: 'application/json',
                'Content-Type': 'application/json',
                'Authorization': 'Basic ' + base64.encode('user:password')
            }
        }

        fetch(`http://url`,data)
        .then((response)=>response.json())
        .then((json)=>{
            console.log(json);
        })

 

 

 

 

 

공격자

1. accessToken 탈취

  - 만료기간이 짧아 시간이 지나면 자연스레 사용 불가

 

2. refreshToken 탈취

 - 이중 로그인 시 가장 마지막에 로그인한 refresh Token만 가능 (새로이 갱신이 되므로)

   이전의 refreshToken은 사용 불가

 

 

단점) 이렇게 하면 서버 쪽에 (굳이 서버쪽 아니고 위에서는 DB) 저장을 해두고 사용해야됨.

       또한 생각보다 저 과정이 자주 일어나서 리소스가 빡쎄다

스크롤 뷰 안에 flatList를 넣으려고 할 때 위와 같은 메세지가 출력된다.

Warning error

 

<FlatList nestedScrollEnabled />

 

React Native 0.41 이상일 경우

<ScrollView
    ref={ref => this.scrollView = ref}
    onContentSizeChange={(contentWidth, contentHeight)=>{        
        this.scrollView.scrollToEnd({animated: true});
    }}>
</ScrollView>

 

flatList에서

 

<FlatList

      ref={'flatList'}

      data={this.state.message}

      renderItem={({ item }) => this._onRefresh(item)}

      keyExtractor={(itemindexnumber=> { return index.toString() }}

     onContentSizeChange={(contentWidthcontentHeight)=>{

           (this.refs.flatList as FlatList).scrollToEnd({animated: true});

           }}

/>

 

 

 

+ Recent posts