Why react component libraries prefer prop based styling - react-bootstrap

If we are using react component libraries we need to pass style in props, how this aproach is helpful than setting bootstrap style inside className

We can do bootstrap styling. There is nothing wrong with it, by writing className and giving bootstrap class name and everything.
But in react, we can create a component which means we can divide our App into smaller app and control the inside data through props and state. So by passing the style through props gives us more flexibility, we can customize the component design based on its data. I think this is the main feature that we can get.

Related

How to pass data from ASP.NET View to React component in ReactJS.NET

I'm trying out ReactJS.NET in a .NET Core MVC project where I've got an ASP.NET View (cshtml) with a React component in it, which I initialize with:
<script src="#Url.Content("~/Scripts/myComponent.jsx")"></script>
Now I want to pass data from the ASP.NET View to the React component. For example, calling a React function when I click a button on the ASP.NET View. Is this possible? I know it's a basic question but I couldn't find any help since in all examples the data is only passed between React components and not from outside (ASP.NET View).
I couldn't find a way to do what I described in this question. So I ended up coding the whole page in ReactJS, which took some time to get into but it worked out well and I didn't have to mix technologies.
Declare a JS variable in a script and assign a property value from the Model:
<script type="text/javascript">let modelProperty= '#Model.ModelProperty';</script>
<script src="#Url.Content("~/Scripts/myComponent.jsx")"></script>
Then use that modelProperty in your ReactJS script:
ReactDOM.render(<MyComponent prop0={modelProperty} />, document.getElementById("yourTargetElementId"))
Maybe there are more neat solutions...

How to manage React Js to multiple page app not using routes?

I want to implement react js to different pages of my website,
e.g
in home page, registration, login, etc.
all tutorial i have seen it only uses 1 app.js how can i achieve this
to multi page app.
P.S i am using laravel elixir and i combine them into 1 main.js.
Add a mounting point in the pages that you want your React App to be mounted.
e.g.
// main.js
ReactDOM.render(<App props={/* props from somewhere */}/>, document.getElementById('mountingPoint') );
// rendered HTML from pages should have
<div id="mountingPoint"></div>
I found this https://github.com/christianalfoni/react-webpack-cookbook/wiki/Multiple-entry-points
I think this is more appropriate on what i need and then i will just map the file
name in my laravel app.
this way i dont need to load the js code for contact_us.php to login.php
You could also use something like React Habitat to make this architecture easier.
With it, you could just define a container of your components so they resolve in your DOM.
For example, in your javascript you would do
import MyComponent from './Components/MyComponent';
...
container.register(MyComponent).as(myComponent);
Then in any of your HTML pages
<div data-component="myComponent"></div>
It also supports multiple containers and async code splitting.

CKEditor prevents framework's and native events propagation

I am having an angular directive that is compiled and inserted into CKEditor. Furthermore i have a widget plugin that upcasts those directives to widgets and allows few of their fields for editing. In those fields there is <input> bound to a model that should be displayed in and out of the editor. Exploring the DOM I see that angular has added its classes for binding, but after attaching a watcher to the model, it turns out that no event is fired when somebody is writing inside the <input>.
Is CKEditor preventing/hiding those events?
Thank you in advance!

Joomla: make a component act like a content plugin

I've created an admin component and now need to insert text on each page of the installing client. So I thought of using the function onContentPrepare but it's a method of a JPlugin class (a content plugin class to be exact).
Is there a way to invoke the component from the view in the same way like a plugin?
Short answer: No, you have to write a plugin. But that's not a big thing.
Long answer: On each request, exactly one component is called. Plugins are triggered at certain events within the control flow. The onContentPrepare event is triggered by the components (not from the Joomla! framework), so some components might not support it. Nevertheless, you can get access to the content of any component through plugins anyway - just use the onAfterRender event of the system plugins.

MVVM and masked input

There is no masked input control in KendoUI framework. But I need to have a mask input capabilities for textboxes as well as for datepicker.
The application mostly based on MVVM with Kendo Templates. So I need a solution compatible with it.
What is the best way to go with our problem? Currently i'm looking at several solutions:
Have a custom widget (as kendo plugin) that is connected with jquery.inputmask plugin.
Have a custom binding that connects a widget and jquery.inputmask plugin
Invoke a jQuery code $(..).input. The problem with this approach that it hard to get it invoked after template is rendered
Basically I the cleanest solution I can suggest you is to create custom Widget or extend one of the existing.
Take a look at the the following example we created - it demonstrates how to extend the datepicker widget custom logic:
http://jsfiddle.net/7JA74/10/
A part from this please notice there is some malfunctioning when a value is selected from the date picker.

Resources