react-native Navigator (navbar) Hiding View Under Navbar
Date : March 29 2020, 07:55 AM
Any of those help I'm having a hard time figuring out which props I need to change in the initial view below the Navbar. Or is there a prop for the navbar I need to change? Basically, the navbar is hiding the top portion of the underlying view. I'm attaching a screen cap here: , Give your signin.js container some marginTop. That will get it done.
|
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I'm trying to right align a navbar item (Contribute) within a navbar.js but I can't seem to figure it out. The navbar is a React component and looks like the following, , The below code solved my issue of alignment. var NavMenu = React.createClass({
render: function(){
var links = this.props.links.reduce(function(acc, current){
current.dropdown ? acc.rightNav.push(current) : acc.leftNav.push(current);
return acc;
}, { leftNav: [], rightNav: [] });
return (
<div>
<ul className="nav navbar-nav">
{links.leftNav.map( function(link) {
return <NavLink key={link.text} linkTo={link.linkTo} text={link.text} active={link.active} />
})}
</ul>
{
links.rightNav.length > 0 ?
<ul className="nav navbar-nav navbar-right">
{
links.rightNav.map( function(link) {
return <NavLinkDropdown key={link.text} links={link.links} text={link.text} active={link.active} />
})
}
</ul> : false
}
</div>
);
}
});
|
React styled-components theme-provider dynamic theme
Date : March 29 2020, 07:55 AM
Hope this helps Something like this? Demoimport React, { Component } from 'react';
import { render } from 'react-dom';
import styled, { ThemeProvider } from 'styled-components';
const themes = {
'light': {
main: '#EFEFEF',
},
'dark': {
main: '#666',
}
}
const DynamicDiv = styled.div`
background: ${({ theme }) => theme.main};
`
class App extends Component {
constructor() {
super();
this.state = {
name: 'React',
theme: themes['light']
};
}
handleDark = () => {
this.setState({ theme: themes['dark'] })
}
render() {
return (
<ThemeProvider theme={this.state.theme}>
<div>
<DynamicDiv>{this.state.name}</DynamicDiv>
<div onClick={this.handleDark}>Change to Dark</div>
</div>
</ThemeProvider>
);
}
}
render(<App />, document.getElementById('root'));
|
Bootstrap v4 navbar , navbar-toggler-icon not working with react
Date : March 29 2020, 07:55 AM
To fix the issue you can do I am not sure how no one caught this or how I forgot, but you need to import jquery before bootstrap. So the new code is: <!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
</head>
<body>
<div id="root"></div>
<!-- Turbo library imports: jQuery, Turbo CDN, sample app.js -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
<script type="text/javascript" src="/dist/js/vendor.min.js"></script>
<script type="text/javascript" src="https://cdn.turbo360-dev.com/dist/turbo.min.js"></script>
<script type="text/javascript" src="/dist/bundle/commons.js"></script>
<script type="text/javascript" src="/dist/bundle/app.js"></script> <!-- React code bundle -->
</body>
</html>
|
How to created Public Navbar and Protected Navbar with React and Redux?
Date : March 29 2020, 07:55 AM
With these it helps first to render navbar u can use condition depending on auth like this: const render_user = () => {
if (auth) {
return (
<NavItem eventKey={1} title="Item">
Welcome User
</NavItem>
);
} else {
return (
<>
<NavItem eventKey={1} title="Item">
<li className="RightNav">
<Link to="/login">Log In</Link>
</li>
</NavItem>
<NavItem eventKey={2} title="Item">
<li className="RightNav">
<Link to="/register">Sign Up</Link>
</li>
</NavItem>
</>
);
}
};
const App = () => {
return (
<Provider store={store}>
<Router>
<div>
<Switch>
<Route exact path="/login" component={Login} />
<Route exact path="/register" component={Register} />
<Route component={DefaultLayout} />
</Switch>
</div>
</Router>
</Provider>
);
};
const DefaultLayout = () => (
<div className="container">
<Navigationbar />
<Route path="/" exact component={Home} />
</div>
);
|